Remove recursion in plot_ica_components and use context manager for plt.ion/plt.ioff#11696
Remove recursion in plot_ica_components and use context manager for plt.ion/plt.ioff#11696larsoner merged 8 commits intomne-tools:mainfrom
Conversation
| 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.
That part is what is hanging jupyter notebooks and spyder consoles.
There was a problem hiding this comment.
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.
... 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_componentsto remove recursion and gather all figures beforeplt.show.