-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove recursion in plot_ica_components and use context manager for plt.ion/plt.ioff #11696
Conversation
mne/viz/_mpl_figure.py
Outdated
plt.ion() | ||
BACKEND = get_backend() | ||
# This ↑↑↑↑↑↑↑↑↑↑↑↑↑ does weird things: | ||
# https://github.com/matplotlib/matplotlib/issues/23298 | ||
# but wrapping it in ion() context makes it go away (can't actually use | ||
# `with plt.ion()` as context manager, though, for compat reasons). | ||
# Moving this bit to a separate function in ../../fixes.py doesn't work. | ||
plt.ioff() |
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.
That part is what is hanging jupyter notebooks and spyder consoles.
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 right thing to do here would be to take advantage of the context-manager capabilities (available in 3.4 already which is our min req, probably wasn't the case when this comment was written as context-manager support isn't available in 3.3) like:
with plt.ion():
BACKEND = get_backend()
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.
... and if you could please do this in mne/viz/backends/_notebook.py
as well, it would be much appreciated! (Found via git grep
when looking into this issue in our repo...)
Labeling as backport candidate since I was hitting this issue before the 1.4 cut and the min version that supports context managing was listed as mpl 3.4 for MNE 1.4 👍 |
Done, good point for the context manager, glad we can use it 😄 |
Yeah we should. Looks like for the feedstock at least we're just out of date: https://github.com/conda-forge/mne-feedstock/blob/main/recipe/meta.yaml#L63 |
Awesome, thanks @mscheltienne ! |
* upstream/main: (32 commits) MAINT: Update download buttons [skip azp] [skip actions] [skip cirrus] Fix canvas.draw() in callback (mne-tools#11697) Remove recursion in plot_ica_components and use context manager for plt.ion/plt.ioff (mne-tools#11696) Update affiliation (mne-tools#11695) BUG: Fix bug with fwd restriction (mne-tools#11694) MRG: Suggest using "conda rename" in MNE updating instructions (mne-tools#11692) FIX: Regex [ci skip] MAINT: Apply deprecations [circle deploy] (mne-tools#11687) MAINT: Release 1.4.0 (mne-tools#11686) Trap music (mne-tools#11679) Fix call to plot_tfr_topomap from interactive AverageTFR.plot_topo function (mne-tools#11683) silence spectrum plot warning in examples/tutorials [circle full] (mne-tools#11682) Spectrum plot picks (mne-tools#11680) Update website conf (mne-tools#11675) BUG: Fix bug with MF LCMV rank (mne-tools#11664) ENH: Change known_config_types to dict (mne-tools#11166) MAINT: Improve README (mne-tools#11673) MAINT: Add to git-blame-ignore-revs [circle front] MAINT: Run black on codebase MAINT: Use black ...
Closes #11693
Closes #11510 (lucky hit, that was the same bug at play)
Prevents spyder console and jupyter notebook from hanging because of:
And restructure
plot_ica_components
to remove recursion and gather all figures beforeplt.show
.