-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move integerness checks to SubplotSpec._from_subplot_args. #17350
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
7b4a234
to
5fb27ba
Compare
I agree that this is nicer to not re-do the checks in two spots, but I feel you've gone a few steps too far here. Reading the code I'd have no idea where these checks were going to be done. I think burying them in Also do all the other subplot classes have these checks? If not, they now no longer have them, whereas before they did... Can we instead just add a helper to |
.. see a revised #17344 for a refactor along these lines, but I think a little more clear, if redundant. |
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 see, SubplotSpec._from_subplot_args
gets called in the init to subplotBase, and all subplots have this base from the factory, so this change is OK.
However, we need to include the documentation changes from #17344. I don't think this feature should be undocumented.
added the docstring changes. |
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 understand the benefit of this, but moving the normalization to after _process_projection_requirements
(and thus _make_key
) means that the key of the Axes
is inconsistent. This means that fig.add_subplot(111)
and fig.add_subplot(1, 1, 1)
are no longer the same, i.e., on master:
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax0 = fig.add_subplot(111)
>>> ax1 = fig.add_subplot(1, 1, 1)
__main__:1: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
>>> ax0 is ax1
True
but now:
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax0 = fig.add_subplot(111)
>>> ax1 = fig.add_subplot(1, 1, 1)
>>> ax0
<matplotlib.axes._subplots.AxesSubplot object at 0x7f22cb92b8d0>
>>> ax1
<matplotlib.axes._subplots.AxesSubplot object at 0x7f22cb537d68>
>>> ax0 is ax1
False
I think thats fine. We are trying to deprecate the key behaviour anyway. |
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 genuinely don't like add_subplot(n, m, (j, k))
, but of course we shouldn't break it.
This seems reasonable; modulo the comments.
a3b59c3
to
deb7b6a
Compare
bf6cd0f
to
912b184
Compare
Fixed @QuLogic's concern by adding a single conversion of 3-digit integers to (i, j, k) -- any invalid value will just pass through and still trigger error handling via SubplotSpec._from_subplot_args. |
This generates numerous warnings like this in the doc build:
|
This avoids having to later do them same for other places (axes_grid) which rely on the same machinery to convert three-digit specifications. I'll assume that the already existing deprecation note for add_subplot is effectively sufficient.
oops |
We talked about this on the weekly call and after some discussion settled on restoring |
that's fixed |
This avoids having to later do them same for other places (axes_grid)
which rely on the same machinery to convert three-digit specifications.
I'll assume that the already existing deprecation note for add_subplot
is effectively sufficient.
Alternative for #17344; only one of them is RC, of course.
Closes #17343.
PR Summary
PR Checklist