Skip to content

Convert hold-related functions to attribute assignments.#328

Merged
WeatherGod merged 2 commits intomatplotlib:masterfrom
efiring:kill_hold
Jan 11, 2017
Merged

Convert hold-related functions to attribute assignments.#328
WeatherGod merged 2 commits intomatplotlib:masterfrom
efiring:kill_hold

Conversation

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

efiring commented Nov 27, 2016

Refer to matplotlib/matplotlib#7516 in mpl.

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

or True, None... whateer...

@efiring
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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