-
Notifications
You must be signed in to change notification settings - Fork 245
Deprecate xshift (X) and yshift (Y) aliases from all plotting modules (remove in v0.12.0) #2071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
1b612e8
0b10141
172714f
e22c16c
fb53e50
3d4934c
e5364b8
e1df24d
3505b6b
b53a574
5e76789
25e097a
594ec3f
444071d
e195e80
94dc0ae
acb01fe
54ec0b0
a11ea8b
bb17675
31823e3
8d62ddd
0f6f626
fef1a49
bd2b05f
a167be3
b5329fd
27d0a70
256abfd
e80797c
4ead194
ea0e730
18bbcc8
3e76319
691d81d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,15 +93,6 @@ | |
| "W": """\ | ||
| pen : str | ||
| Set pen attributes for lines or the outline of symbols.""", | ||
| "XY": r""" | ||
| xshift : str | ||
| [**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*]. | ||
| Shift plot origin in x-direction. | ||
| yshift : str | ||
| [**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*]. | ||
| Shift plot origin in y-direction. Full documentation is at | ||
| :gmt-docs:`gmt.html#xy-full`. | ||
| """, | ||
| "a": r""" | ||
| aspatial : bool or str | ||
| [*col*\ =]\ *name*\ [,...]. | ||
|
|
@@ -574,6 +565,14 @@ def new_module(*args, **kwargs): | |
| f"Parameters in short-form ({short_param}) and " | ||
| f"long-form ({long_alias}) can't coexist." | ||
| ) | ||
| if (long_alias in kwargs and long_alias in ["xshift", "yshift"]) or ( | ||
| short_param in kwargs and short_param in ["X", "Y"] | ||
| ): | ||
| raise GMTInvalidInput( | ||
| f"Parameters ({short_param}) and " | ||
| f"({long_alias}) are not supported anymore." | ||
| f" Please use shift_origin() instead!" | ||
| ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using an error here will immediately break people's code if they're using One idea is to use the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We don't have to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at #924 (comment), I think the intention was to remove xshift/yshift from the docstring, not completely from the code. I.e. the aliases should still work (with a FutureWarning) for at least 2 more minor versions. But maybe I'm missing some context here, was there a discussion to drop xshift/yshift in a backward incompatible way?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, we definitely need backward compatibility. The final goal is, for the next 2 or more minor versions, users can still use parameters
I believe this will work but it's not ideal. It's easy to modify the The error message can't recommend using It's also more confusing when users use the short parameters
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've opened PR #2135, which shows how we can deprecate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I applied your implemetations for this PR @seisman. |
||
| if long_alias in kwargs: | ||
| kwargs[short_param] = kwargs.pop(long_alias) | ||
| elif short_param in kwargs: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't works, because after removing
X="xshift"andY="yshift"from theuse_aliasdecorator, the variablealiasesat line 571 no longer contain the paramtersxshiftoryshift.Instead, after line 583, you can check if any of
xshift,yshift,XandYexists inkwargs. If yes, then raise an warning. For backward compatibility, you also need to do the "xshift"->X and "yshift"->"Y" conversions if "xshift" or "yshift" is used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, you mean to leave
X="xshift" and Y="yshift"as is in each function and add the others at this point, too @seisman ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Changes to other files (e.g.,
basemap.py) make sense to me. The only thing that is missing is how to correctly check if users usexshift,yshift,XorY. The checking should be done in thepygmt/helpers/decorators.pyfile.