-
Notifications
You must be signed in to change notification settings - Fork 371
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
Deprecate old lat/lon tick label formatters #1066
base: main
Are you sure you want to change the base?
Conversation
lib/cartopy/mpl/gridliner.py
Outdated
_LATITUDE_FORMATTER = mticker.FuncFormatter(lambda v, pos: | ||
_north_south_formatted(v)) | ||
|
||
def deprecated_formatter(old_formatter, old_formatter_name, new_formatter_name): |
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.
E302 expected 2 blank lines, found 1
E501 line too long (80 > 79 characters)
lib/cartopy/mpl/gridliner.py
Outdated
DeprecationWarning) | ||
return old_formatter | ||
|
||
LONGITUDE_FORMATTER = deprecated_formatter( |
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.
E305 expected 2 blank lines after class or function definition, found 1
lib/cartopy/mpl/gridliner.py
Outdated
_north_south_formatted(v)) | ||
|
||
|
||
def deprecated_formatter(old_formatter, old_formatter_name, new_formatter_name): |
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.
E501 line too long (80 > 79 characters)
b7a687e
to
8c93811
Compare
Would it be better to use matplotlib's deprecation infrastructure rather than adding our own? |
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.
You should be wary because the two formatters are not entirely equivalent, and there are some potential pitfalls with the newer one (see #401 (comment)). The differences are subtle, but there may be use cases that the originals serve better.
There are also issues with your proposed deprecation implementation that need consideration.
return old_formatter | ||
|
||
|
||
LONGITUDE_FORMATTER = deprecated_formatter( |
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.
You are calling the function immediately when the module is imported, so this warning will always be shown regardless of whether the user actually wants to use LONGITUDE_FORMATTER
or LATITUDE_FORMATTER
. I think this will create too much noise and not target those people you want to see the warning.
Do you just mean using mplDeprecation, like matplotlib/matplotlib#7723 ? |
Matplotlib has a |
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.
Thanks @lbdreyer! 👍 for deprecating this.
There are two issues that need to be addressed:
- DeprecationWarnings are hidden by default, thus unless you engage with them, you'll never know about this until they are actually removed from the codebase (in which case, we may as well just remove them now and be done with it). A UserWarning is fine with me.
- Don't invoke the deprecation warning on module import
@lbdreyer - any chance you've got some time to spin this back up? Would be good to target this for v0.18. |
Wouldn't this PR be suitable for the next release? I think the pitfall mentioned in #401 (comment) is no longer relevant in version 0.18: cartopy/lib/cartopy/mpl/gridliner.py Lines 194 to 208 in 178a15e
Matplotlib's Now that version 0.18 makes One thing you could also do is add |
We have two (2) longitude and latitude tick formatters.
cartopy.mpl.gridliner.LONGITUDE_FORMATTER which is ~5 years old
and
cartopy.mpl.ticker.LongitudeFormatter which is ~ 4 years old
The newer one is better as it allows the user to modify the number format, etc.
I'm not sure why the old one wasn't removed when the new one was added, the code is so similar!
I think we should deprecate the older version in preference for the newer one and update all the places it gets used (e.g. in the cartopy course)