Skip to content

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

Merged
merged 2 commits into from
Jan 11, 2017

Conversation

efiring
Copy link
Member

@efiring efiring commented Nov 27, 2016

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.

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.
@efiring
Copy link
Member Author

efiring commented Nov 27, 2016

Refer to matplotlib/matplotlib#7516 in mpl.

@WeatherGod
Copy link
Member

sorry, I missed this earlier this month. This makes sense to do, but perhaps we should be doing getattr(ax, '_hold', False) to be future-proof?

@WeatherGod
Copy link
Member

or True, None... whateer...

@efiring
Copy link
Member Author

efiring commented Jan 11, 2017

@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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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'):
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants