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

Skip to content

Commit fe701e3

Browse files
committed
Merge pull request #5778 from mdboom/blacklist-warning
Fix #5777. Don't warn when applying default style
2 parents c849398 + c515a9d commit fe701e3

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

lib/matplotlib/style/core.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@
4343
'savefig.directory', 'tk.window_focus', 'hardcopy.docstring'])
4444

4545

46-
def _remove_blacklisted_style_params(d):
46+
def _remove_blacklisted_style_params(d, warn=True):
4747
o = {}
4848
for key, val in d.items():
4949
if key in STYLE_BLACKLIST:
50-
warnings.warn(
51-
"Style includes a parameter, '{0}', that is not related to "
52-
"style. Ignoring".format(key))
50+
if warn:
51+
warnings.warn(
52+
"Style includes a parameter, '{0}', that is not related "
53+
"to style. Ignoring".format(key))
5354
else:
5455
o[key] = val
5556
return o
@@ -60,8 +61,8 @@ def is_style_file(filename):
6061
return STYLE_FILE_PATTERN.match(filename) is not None
6162

6263

63-
def _apply_style(d):
64-
mpl.rcParams.update(_remove_blacklisted_style_params(d))
64+
def _apply_style(d, warn=True):
65+
mpl.rcParams.update(_remove_blacklisted_style_params(d, warn=warn))
6566

6667

6768
def use(style):
@@ -98,7 +99,7 @@ def use(style):
9899
if not cbook.is_string_like(style):
99100
_apply_style(style)
100101
elif style == 'default':
101-
_apply_style(rcParamsDefault)
102+
_apply_style(rcParamsDefault, warn=False)
102103
elif style in library:
103104
_apply_style(library[style])
104105
else:

lib/matplotlib/tests/test_backend_qt4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from matplotlib.testing.decorators import cleanup, switch_backend
88
from matplotlib.testing.decorators import knownfailureif
99
from matplotlib._pylab_helpers import Gcf
10-
import matplotlib.style as mstyle
10+
import matplotlib
1111
import copy
1212

1313
try:
@@ -17,7 +17,7 @@
1717
import mock
1818

1919
try:
20-
with mstyle.context({'backend': 'Qt4Agg'}):
20+
with matplotlib.rc_context(rc={'backend': 'Qt4Agg'}):
2121
from matplotlib.backends.qt_compat import QtCore
2222

2323
from matplotlib.backends.backend_qt4 import (MODIFIER_KEYS,

lib/matplotlib/tests/test_backend_qt5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from matplotlib.testing.decorators import cleanup, switch_backend
77
from matplotlib.testing.decorators import knownfailureif
88
from matplotlib._pylab_helpers import Gcf
9-
import matplotlib.style as mstyle
9+
import matplotlib
1010
import copy
1111

1212
try:
@@ -16,7 +16,7 @@
1616
import mock
1717

1818
try:
19-
with mstyle.context({'backend': 'Qt5Agg'}):
19+
with matplotlib.rc_context(rc={'backend': 'Qt5Agg'}):
2020
from matplotlib.backends.qt_compat import QtCore, __version__
2121
from matplotlib.backends.backend_qt5 import (MODIFIER_KEYS,
2222
SUPER, ALT, CTRL, SHIFT)

0 commit comments

Comments
 (0)