Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix invalid checks for axes_class parameter in ImageGrid. #15461

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 1 commit into from
Nov 9, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 21, 2019

The validation of the axes_class parameter in the Grid and ImageGrid
class have been wrong ever since they were merged in in f44235e
(relevant followup commits: 7482fdc, a5e67b9).

  • In Grid, self._defaultAxesClass has never been a class with its own
    .Axes attribute, so the subclass check would fail with an
    AttributeError.
  • In ImageGrid, the isinstance(axes_class, Axes) check should be
    issubclass(...) instead. (The code later calls axes_class(...)
    to build an axes instance so if one really passed an axes instance,
    the call would raise an exception as axes are not callable.)

Fix these checks. As a consequence, there was no previously valid
path where axes_class_args would have been set, and passing a
(class, args) pair is not documented anyways, so drop that
"functionality" (which never worked).

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

flake8:

./lib/mpl_toolkits/axes_grid1/axes_grid.py:5:1: F401 'matplotlib.axes as maxes' imported but unused

The validation of the axes_class parameter in the Grid and ImageGrid
class have been wrong ever since they were merged in in f44235e
(relevant followup commits: 7482fdc, a5e67b9).

- In Grid, self._defaultAxesClass has never been a class with its own
  .Axes attribute, so the subclass check would fail with an
  AttributeError.
- In ImageGrid, the `isinstance(axes_class, Axes)` check should be
  `issubclass(...)` instead.  (The code later calls `axes_class(...)`
  to build an axes instance so if one really passed an axes instance,
  the call would raise an exception as axes are not callable.)

Fix these checks.  As a consequence, there was no previously valid
path where axes_class_args would have been set, and passing a
`(class, args)` pair is not documented anyways, so drop that
"functionality" (which never worked).
@anntzer
Copy link
Contributor Author

anntzer commented Oct 21, 2019

thanks, fixed

@anntzer anntzer force-pushed the axes_grid-axes_class branch 4 times, most recently from a5922c8 to 22b614b Compare October 21, 2019 21:14
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.

As a consequence, there was no previously valid
path where axes_class_args would have been set, and passing a
(class, args) pair is not documented anyways, so drop that
"functionality" (which never worked).

Agreed.

@dstansby dstansby added this to the v3.3.0 milestone Nov 9, 2019
@dstansby dstansby merged commit f7e7e46 into matplotlib:master Nov 9, 2019
@anntzer anntzer deleted the axes_grid-axes_class branch November 9, 2019 12:25
@tacaswell
Copy link
Member

This did used to work and is used in the cartopy documentation (https://scitools.org.uk/cartopy/docs/latest/gallery/axes_grid_basic.html) so we should put it back, I will have a PR open shortly.

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.

4 participants