10000 Fix use of --pylab=auto and --matplotlib=auto (#14403) · ipython/ipython@3b57430 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b57430

Browse files
authored
Fix use of --pylab=auto and --matplotlib=auto (#14403)
Fixes #14401 which has been a bug in the 8.22.x and 8.23.x releases. When I removed the multiple initialisation of Matplotlib backends in #14330 it broke use of the following: ```bash ipython --matplotlib ipython --matplotlib=auto ipython --pylab ipython --pylab=auto ``` by failing to display Matplotlib plot. If you specify a particular GUI event loop such as using ```bash ipython --pylab=qt ``` then it was and is fine. So for anyone finding this, the workaround until the next release is to specify a GUI loop rather than relying on the auto selection. I didn't notice this as I've been concentrating on moving the Matplotlib backend logic from IPython to Matplotlib, and with those changes (matplotlib/matplotlib#27948) the above use cases all work OK. The fix is to reintroduce the early import of `matplotlib-inline` but only if both the gui loop is not specified and the Matplotlib version is before the movement of the backend logic across to it. There are no explicit tests for this. In the future I will try to think of some tests for some of this IPython-Matplotlib functionality that don't involve installing complicated backend dependencies or adding image comparison tests.
2 parents e0d3e4c + 44e25c7 commit 3b57430

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

IPython/core/interactiveshell.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,6 +3654,13 @@ def enable_matplotlib(self, gui=None):
36543654
make sense in all contexts, for example a terminal ipython can't
36553655
display figures inline.
36563656
"""
3657+
from .pylabtools import _matplotlib_manages_backends
3658+
3659+
if not _matplotlib_manages_backends() and gui in (None, "auto"):
3660+
# Early import of backend_inline required for its side effect of
3661+
# calling _enable_matplotlib_integration()
3662+
import matplotlib_inline.backend_inline
3663+
36573664
from IPython.core import pylabtools as pt
36583665
gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
36593666

0 commit comments

Comments
 (0)
0