-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Restore _AxesStack to track a Figure's Axes order. #19625
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
lib/matplotlib/figure.py
Outdated
_api.check_isinstance(Axes, a=a) | ||
|
||
if a in self: | ||
return None |
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.
probably should test this since it seems someone could change this?
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'll check further, but this may not ever happen, as the Figure.add_*
might handle that already now.
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.
There are 3 effects of this early return
:
- A different return value, but
_AxesStack.add
is only called from_add_axes_internal
, and that doesn't care about the return value. - The
Axes
doesn't get added to the stack multiple times, but that's what we want anyway. - The
Axes
would not be made current (i.e., moved to the end), but there's asca
in_add_axes_internal
, so we don't need to worry about that.
I thought some tests checked add_axes
/add_subplot
with an existing Axes
, but it appears not if this isn't getting coverage. I will add some more tests and remove the return value, which no-one uses.
To summarize?
|
ac394fc
to
518d064
Compare
@@ -622,9 +622,6 @@ def __len__(self): | |||
def __getitem__(self, ind): | |||
return self._elements[ind] | |||
|
|||
def as_list(self): |
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.
Why is this method removed?
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.
It was moved from _AxesStack
to the base class; now that _AxesStack
is back, it's not needed there. Better not to add more public API if not necessary.
518d064
to
3817c80
Compare
I'll wait until today's meeting to merge in case there are any other issues but I think this is good. |
So we can merge now? |
yes 😄 |
I don't know why meeseeks is randomly not backporting. @meeseeksdev backport to v3.4.x |
…625-on-v3.4.x Backport PR #19625 on branch v3.4.x (Restore _AxesStack to track a Figure's Axes order.)
PR Summary
This is a simplified version of the
AxesStack
removed in #19153, but removing the key entry, and just tracking the index with theAxes
. We no longer need to track keys.Fixes #19598.
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).