From 106b34180b4a276c6f2ce9fd071d408205da478d Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Wed, 5 Sep 2018 23:51:56 +0200 Subject: [PATCH] Backport PR #12022: Remove intent to deprecate rcParams["backend_fallback"]. --- lib/matplotlib/pyplot.py | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 265ca857ef88..3ab2a6549e7a 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -72,26 +72,6 @@ _log = logging.getLogger(__name__) -## Backend detection ## - - -# FIXME: Deprecate. -def _backend_selection(): - """ - If rcParams['backend_fallback'] is true, we will check (at backend - load-time) to see if the current backend is compatible with the current - running event loop, and if not switches to a compatible one. - """ - if rcParams["backend_fallback"]: - if (dict.__getitem__(rcParams, "backend") in _interactive_bk - and _get_running_interactive_framework()): - dict.__setitem__( - rcParams, "backend", rcsetup._auto_backend_sentinel) - - -_backend_selection() - - ## Global ## @@ -2380,16 +2360,23 @@ def _autogen_docstring(base): return lambda func: addendum(docstring.copy_dedent(base)(func)) -# just to be safe. Interactive mode can be turned on without +# If rcParams['backend_fallback'] is true, and an interactive backend is +# requested, ignore rcParams['backend'] and force selection of a backend that +# is compatible with the current running interactive framework. +if (rcParams["backend_fallback"] + and dict.__getitem__(rcParams, "backend") in _interactive_bk + and _get_running_interactive_framework()): + dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel) +# Set up the backend. +switch_backend(rcParams["backend"]) + +# Just to be safe. Interactive mode can be turned on without # calling `plt.ion()` so register it again here. # This is safe because multiple calls to `install_repl_displayhook` # are no-ops and the registered function respect `mpl.is_interactive()` # to determine if they should trigger a draw. install_repl_displayhook() -# Set up the backend. -switch_backend(rcParams["backend"]) - ################# REMAINING CONTENT GENERATED BY boilerplate.py ##############