Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b31c5ae

Browse filesBrowse files
authored
Merge pull request #23057 from tacaswell/fix_pylab
2 parents 8e34e70 + 80ebea5 commit b31c5ae
Copy full SHA for b31c5ae

File tree

Expand file treeCollapse file tree

2 files changed

+28
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-6
lines changed

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,6 @@ def _get_backend_mod():
203203
# will (re)import pyplot and then call switch_backend if we need to
204204
# resolve the auto sentinel)
205205
switch_backend(dict.__getitem__(rcParams, "backend"))
206-
# Just to be safe. Interactive mode can be turned on without calling
207-
# `plt.ion()` so register it again here. This is safe because multiple
208-
# calls to `install_repl_displayhook` are no-ops and the registered
209-
# function respects `mpl.is_interactive()` to determine if it should
210-
# trigger a draw.
211-
install_repl_displayhook()
212206
return _backend_mod
213207

214208

@@ -323,6 +317,10 @@ def new_figure_manager(num, *args, FigureClass=Figure, **kwargs):
323317
# See https://github.com/matplotlib/matplotlib/issues/6092
324318
matplotlib.backends.backend = newbackend
325319

320+
# make sure the repl display hook is installed in case we become
321+
# interactive
322+
install_repl_displayhook()
323+
326324

327325
def _warn_if_gui_out_of_main_thread():
328326
if (_get_required_interactive_framework(_get_backend_mod())

‎lib/matplotlib/tests/test_pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_pyplot.py
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import difflib
22
import numpy as np
3+
import os
34
import subprocess
45
import sys
56
from pathlib import Path
@@ -367,3 +368,26 @@ def test_set_current_axes_on_subfigure():
367368
assert plt.gca() != ax
368369
plt.sca(ax)
369370
assert plt.gca() == ax
371+
372+
373+
def test_pylab_integration():
374+
pytest.importorskip("IPython")
375+
subprocess.run(
376+
[
377+
sys.executable,
378+
"-m",
379+
"IPython",
380+
"--pylab",
381+
"-c",
382+
";".join((
383+
"import matplotlib.pyplot as plt",
384+
"assert plt._REPL_DISPLAYHOOK == plt._ReplDisplayHook.IPYTHON",
385+
)),
386+
],
387+
env={**os.environ, "SOURCE_DATE_EPOCH": "0"},
388+
timeout=60,
389+
check=True,
390+
stdout=subprocess.PIPE,
391+
stderr=subprocess.PIPE,
392+
universal_newlines=True,
393+
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.