Skip to content

Commit 6fa35aa

Browse files
committed
Merge pull request matplotlib#1445 from jrevans/working
JRE - Modified 'use' so that it will only warn if the requested backend is different that what is currently set.
2 parents c63f671 + 6ccdbbc commit 6fa35aa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/matplotlib/__init__.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,18 @@ def use(arg, warn=True, force=False):
999999
:func:`matplotlib.get_backend`.
10001000
10011001
"""
1002+
# Lets determine the proper backend name first
1003+
if arg.startswith('module://'):
1004+
name = arg
1005+
else:
1006+
# Lowercase only non-module backend names (modules are case-sensitive)
1007+
arg = arg.lower()
1008+
name = validate_backend(arg)
1009+
10021010
# Check if we've already set up a backend
10031011
if 'matplotlib.backends' in sys.modules:
1004-
if warn:
1012+
# Warn only if called with a different name
1013+
if (rcParams['backend'] != name) and warn:
10051014
warnings.warn(_use_error_msg)
10061015

10071016
# Unless we've been told to force it, just return
@@ -1011,14 +1020,7 @@ def use(arg, warn=True, force=False):
10111020
else:
10121021
need_reload = False
10131022

1014-
# Set-up the proper backend name
1015-
if arg.startswith('module://'):
1016-
name = arg
1017-
else:
1018-
# Lowercase only non-module backend names (modules are case-sensitive)
1019-
arg = arg.lower()
1020-
name = validate_backend(arg)
1021-
1023+
# Store the backend name
10221024
rcParams['backend'] = name
10231025

10241026
# If needed we reload here because a lot of setup code is triggered on

0 commit comments

Comments
 (0)