-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: Remove deprecated axes kwargs collision detection (version 2) #19153
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
MNT: Remove deprecated axes kwargs collision detection (version 2) #19153
Conversation
a886c4e
to
bcee8ab
Compare
This new behaviour sounds right to me, but have you tested it all? ie. I do not see a test that we create new axes, but maybe I read too quickly. |
@jklymak, I did not add any new unit tests. I only modified existing unit tests so that they would pass. |
bcee8ab
to
e6df62e
Compare
Hi, any feedback on this PR? This is just a gentle poke because the submission was badly timed, right before the holidays. Thank you! |
Please do keep pinging us! OTOH, the ball is still in your court to add new tests for the new behaviour ;-) |
e6df62e
to
f0ca259
Compare
@jklymak, as requested, I added a unit test. |
Thanks a lot, the unit tests really make the new behaviour clear. This all seems reasonable to me, but lets ping @tacaswell, @timhoffm and @QuLogic to make sure we have all that was discussed in #18978 correct. |
f6d425f
to
400aa25
Compare
@timhoffm, thank you, I addressed all of your comments. |
78d231f
to
0db9c6c
Compare
@QuLogic, I believe that I addressed all of your comments. |
0db9c6c
to
2377702
Compare
It looks like you'll need to update the tests for the wording changes. |
In Matplotlib 2.1, the behavior of reusing existing axes when created with the same arguments was deprecated (see matplotlib#9037). This behavior is now removed. The behavior of the functions to create new axes (`pyplot.axes`, `pyplot.subplot`, `figure.Figure.add_axes`, `figure.Figure.add_subplot`) has changed. In the past, these functions would detect if you were attempting to create Axes with the same keyword arguments as already-existing axes in the current figure, and if so, they would return the existing Axes. Now, these functions will always create new Axes. A special exception is `pyplot.subplot`, which will reuse any existing subplot with a matching subplot spec. However, if there is a subplot with a matching subplot spec, then that subplot will be returned, even if the keyword arguments with which it was created differ. Correspondingly, the behavior of the functions to get the current Axes (`pyplot.gca`, `figure.Figure.gca`) has changed. In the past, these functions accepted keyword arguments. If the keyword arguments matched an already-existing Axes, then that Axes would be returned, otherwise new Axes would be created with those keyword arguments. Now, the keyword arguments are only considered if there are no axes at all in the current figure. In a future release, these functions will not accept keyword arguments at all. Fixes matplotlib#18832.
2377702
to
68498c6
Compare
Whoops! Should be fixed now. |
This replaces #18978, and addresses the comments from @tacaswell and @jklymak to preserve the behavior of repeated calls to
plt.subplot
with the same subplot spec.PR Summary
In Matplotlib 2.1, the behavior of reusing existing axes when created with the same arguments was deprecated (see #9037). This behavior is now removed.
The behavior of the functions to create new axes (
pyplot.axes
,pyplot.subplot
,figure.Figure.add_axes
,figure.Figure.add_subplot
) has changed. In the past, these functions would detect if you were attempting to create Axes with the same keyword arguments as already-existing axes in the current figure, and if so, they would return the existing Axes. Now, these functions will always create new Axes. A special exception ispyplot.subplot
, which will reuse any existing subplot with a matching subplot spec. However, if there is a subplot with a matching subplot spec, then that subplot will be returned, even if the keyword arguments with which it was created differ.Correspondingly, the behavior of the functions to get the current Axes (
pyplot.gca
,figure.Figure.gca
) has changed. In the past, these functions accepted keyword arguments. If the keyword arguments matched an already-existing Axes, then that Axes would be returned, otherwise new Axes would be created with those keyword arguments. Now, the keyword arguments are only considered if there are no axes at all in the current figure. In a future release, these functions will not accept keyword arguments at all.Fixes #18832.
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).