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

Sign up
Appearance settings

Commit 9e371a3

Browse files
dopplershiftstory645
authored andcommitted
Backport PR matplotlib#15512: FIX: do not consider webagg and nbagg "interactive" for fallback'
1 parent 83f686c commit 9e371a3

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

‎lib/matplotlib/pyplot.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,8 +2341,9 @@ def getname_val(identifier):
23412341
# requested, ignore rcParams['backend'] and force selection of a backend that
23422342
# is compatible with the current running interactive framework.
23432343
if (rcParams["backend_fallback"]
2344-
and dict.__getitem__(rcParams, "backend") in _interactive_bk
2345-
and _get_running_interactive_framework()):
2344+
and dict.__getitem__(rcParams, "backend") in (
2345+
set(_interactive_bk) - {'WebAgg', 'nbAgg'})
2346+
and cbook._get_running_interactive_framework()):
23462347
dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel)
23472348
# Set up the backend.
23482349
switch_backend(rcParams["backend"])
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import subprocess
2+
import os
3+
import sys
4+
import pytest
5+
6+
7+
@pytest.mark.parametrize("backend", ["webagg", "nbagg"])
8+
def test_webagg_fallback(backend):
9+
if backend == "nbagg":
10+
pytest.importorskip("IPython")
11+
env = {}
12+
if os.name == "nt":
13+
env = dict(os.environ)
14+
else:
15+
env = {"DISPLAY": ""}
16+
17+
env["MPLBACKEND"] = backend
18+
19+
test_code = (
20+
"import os;"
21+
+ f"assert os.environ['MPLBACKEND'] == '{backend}';"
22+
+ "import matplotlib.pyplot as plt; "
23+
+ "print(plt.get_backend());"
24+
f"assert '{backend}' == plt.get_backend().lower();"
25+
)
26+
ret = subprocess.call([sys.executable, "-c", test_code], env=env)
27+
28+
assert ret == 0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /