Skip to content
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

Reuse Grid.__init__ in ImageGrid.__init__. #15670

Merged
merged 1 commit into from Jan 6, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 10, 2019

ImageGrid.__init__ differs from Grid.__init__ by some defaults which
can be passed to the superclass, and by additionally constructing the
colorbar axes. This needs to be pushed into _update_locators which
isn't optimal but still better than duplicating the entire
Grid.__init__.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@timhoffm
Copy link
Member

timhoffm commented Jan 5, 2020

Initializing the colorbar in _update_locators() is unexpected.

Can you make a separate method (something like _update_extra_ax, name up for improvement) for updating the colorbar. The method is empty in Grid. IMHO this is better than doing unrelated stuff in _update_locators.

Alternatively, you could find a more general name instead of _update_locators.

BTW: Is it _update_locators or rather _init_locators()? Currently this is only called during setup; and I think it's not feasible to use this method anywhere again later (currently it is not).

@anntzer
Copy link
Contributor Author

anntzer commented Jan 5, 2020

I just renamed it to _init_locators, as that's what it really is.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for renaming.

lib/mpl_toolkits/axes_grid1/axes_grid.py Show resolved Hide resolved
`ImageGrid.__init__` differs from `Grid.__init__` by some defaults which
can be passed to the superclass, and by additionally constructing the
colorbar axes.  This needs to be pushed into `_update_locators` which
isn't optimal but still better than duplicating the entire
`Grid.__init__`; the method was thus renamed to `_init_locators` (it's
only called during init).
@dopplershift dopplershift merged commit c185494 into matplotlib:master Jan 6, 2020
@anntzer anntzer deleted the axes_grid-dedupe-init branch January 6, 2020 21:47
@QuLogic QuLogic added this to the v3.3.0 milestone Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants