From f439574d803c755a267021067311a634b5f03978 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 22 May 2022 18:26:33 +0200 Subject: [PATCH] Tweak check for IPython pylab mode. We really only care about whether the attribute is present (even nowadays, _needmain is always False; it appears to never have changed in IPython's history). --- lib/matplotlib/backend_bases.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index f70be0d91b94..b397eb0bf2a0 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -3498,14 +3498,11 @@ def show(cls, *, block=None): if cls.mainloop is None: return if block is None: - # Hack: Are we in IPython's pylab mode? + # Hack: Are we in IPython's %pylab mode? In pylab mode, IPython + # (>= 0.10) tacks a _needmain attribute onto pyplot.show (always + # set to False). from matplotlib import pyplot - try: - # IPython versions >= 0.10 tack the _needmain attribute onto - # pyplot.show, and always set it to False, when in %pylab mode. - ipython_pylab = not pyplot.show._needmain - except AttributeError: - ipython_pylab = False + ipython_pylab = hasattr(pyplot.show, "_needmain") block = not ipython_pylab and not is_interactive() # TODO: The above is a hack to get the WebAgg backend working with # ipython's `%pylab` mode until proper integration is implemented. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy