-
Notifications
You must be signed in to change notification settings - Fork 397
Convert hold-related functions to attribute assignments. #328
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
Conversation
This is a minimal change so that the deprecation of "hold" in mpl 2.x won't trigger warnings in Basemap from routine plotting calls.
Refer to matplotlib/matplotlib#7516 in mpl. |
sorry, I missed this earlier this month. This makes sense to do, but perhaps we should be doing |
or True, None... whateer... |
@WeatherGod: good idea to future-proof. I think I have done that now. Maybe I should have used a context-manager, but oh, well. |
h = kwargs.pop('hold', None) | ||
if hasattr(ax, '_hold'): | ||
self._tmp_hold = ax._hold | ||
ax._hold = h |
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.
This assignment only happens if the axes already has a _hold
attribute. So, this wouldn't work if someone was setting the hold initially.
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.
My thinking here is that presently (with 2.x), the _hold attribute is always present. It is set in the AxesBase initializer. Some time in the future it won't be, and at that point Basemap doesn't need to obey it, and shouldn't set it at all.
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.
ah, yeah, that does make sense then. And it prevents basemap from adding the attribute itself if it isn't there already.
ax._hold = h | ||
|
||
def _restore_hold(self, ax): | ||
if hasattr(ax, '_hold'): |
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 would check for hasattr(self, '_tmp_hold')
instead, and then del the attribute when done
This is a minimal change so that the deprecation of "hold"
in mpl 2.x won't trigger warnings in Basemap from routine
plotting calls.