Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
FIX: be very paranoid about checking what the current canvas is#25573
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
anntzer commentedMar 29, 2023
Perhaps the simpler check would be Alternatively, we could additionally record |
tacaswell commentedMar 31, 2023
I think that would still miss the "middle removed" issue as we have references that skip generations and we should avoid adding more hard-references than we strictly need.... But I will change to |
54db976 to7100b57CompareUh oh!
There was an error while loading.Please reload this page.
anntzer left a comment
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.
Modulo CI, and with an optional additional comment.
tacaswell commentedApr 3, 2023
Hmm, we are back to not being careful enough...but only an azure?! |
anntzer commentedApr 3, 2023
That's a bit fishy, but perhaps just change all the |
a9f4c6c todb2176fComparelib/matplotlib/widgets.py Outdated
| def_clear(self,event): | ||
| """Internal event handler to clear the buttons.""" | ||
| ifself.ignore(event)orself.canvas.is_saving(): | ||
| ifself.ignore(event)orself.canvasisNoneorself.canvas.is_saving(): |
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.
Should the canvas is not None check rather go to a newAxesWidget.ignore? (def AxesWidget.ignore(self, event): return not self.active or self.canvas is None)
Then this change and the one immediately below could go away.
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 agree. This belongs logically in anAxesWidget.ignore().
anntzer left a comment
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 think the patch could be better, but this is also correct.
tacaswell commentedJul 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I tried putting the check in Added a new method and a couple of |
| deftest_parent_axes_removal(): | ||
| fig, (ax_radio,ax_checks)=plt.subplots(1,2) | ||
| radio=widgets.RadioButtons(ax_radio, ['1','2'],0) | ||
| checks=widgets.CheckButtons(ax_checks, ['1','2'], [True,False]) | ||
| ax_checks.remove() | ||
| ax_radio.remove() | ||
| withio.BytesIO()asout: | ||
| fig.savefig(out,format='raw') | ||
| renderer=fig._get_renderer() | ||
| evt=DrawEvent('draw_event',fig.canvas,renderer) | ||
| radio._clear(evt) | ||
| checks._clear(evt) |
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.
This is obviously some kind of smoke test as it does not contain assertions. A short description would be helpful though.
I understand that removal of the buttons should not brick the figure. But what exactly are we testing with the savefig, and what with the _clear calls? (I assume there are actually two separate tests?
9f1da21 to5c83d7bCompare1503ac4 intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
PR Summary
closes#25572
There are many ways for things to end up in odd states, the goal here is to detect if the the canvas has changed under us when trying to manage the state of widgets.
PR Checklist
Documentation and Tests
pytestpasses)Release Notes
.. versionadded::directive in the docstring and documented indoc/users/next_whats_new/.. versionchanged::directive in the docstring and documented indoc/api/next_api_changes/next_whats_new/README.rstornext_api_changes/README.rst