Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99a2e46

Browse files
committed
Remove intent to deprecate rcParams["backend_fallback"].
I had left a note intending to deprecate this rcParam back when the backend-switching API would let the user specify an explicit fallback list. As this feature was not accepted, it makes sense to keep the rcparam. Also move its actual use next to the place where the backend is set up in pyplot.py. Also move the call to install_repl_displayhook after that, as install_repl_displayhook calls get_backend() so we want the rcparam to have taken effect already.
1 parent 248399e commit 99a2e46

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

lib/matplotlib/pyplot.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,6 @@
7272
_log = logging.getLogger(__name__)
7373

7474

75-
## Backend detection ##
76-
77-
78-
# FIXME: Deprecate.
79-
def _backend_selection():
80-
"""
81-
If rcParams['backend_fallback'] is true, we will check (at backend
82-
load-time) to see if the current backend is compatible with the current
83-
running event loop, and if not switches to a compatible one.
84-
"""
85-
if rcParams["backend_fallback"]:
86-
if (dict.__getitem__(rcParams, "backend") in _interactive_bk
87-
and _get_running_interactive_framework()):
88-
dict.__setitem__(
89-
rcParams, "backend", rcsetup._auto_backend_sentinel)
90-
91-
92-
_backend_selection()
93-
94-
9575
## Global ##
9676

9777

@@ -2348,16 +2328,23 @@ def _autogen_docstring(base):
23482328
return lambda func: addendum(docstring.copy_dedent(base)(func))
23492329

23502330

2351-
# just to be safe. Interactive mode can be turned on without
2331+
# If rcParams['backend_fallback'] is true, and an interactive backend is
2332+
# requested, ignore rcParams['backend'] and force selection of a backend that
2333+
# is compatible with the current running interactive framework.
2334+
if (rcParams["backend_fallback"]
2335+
and dict.__getitem__(rcParams, "backend") in _interactive_bk
2336+
and _get_running_interactive_framework()):
2337+
dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel)
2338+
# Set up the backend.
2339+
switch_backend(rcParams["backend"])
2340+
2341+
# Just to be safe. Interactive mode can be turned on without
23522342
# calling `plt.ion()` so register it again here.
23532343
# This is safe because multiple calls to `install_repl_displayhook`
23542344
# are no-ops and the registered function respect `mpl.is_interactive()`
23552345
# to determine if they should trigger a draw.
23562346
install_repl_displayhook()
23572347

2358-
# Set up the backend.
2359-
switch_backend(rcParams["backend"])
2360-
23612348

23622349
################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
23632350

0 commit comments

Comments
 (0)