Skip to content

Commit

Permalink
Merge pull request #5778 from mdboom/blacklist-warning
Browse files Browse the repository at this point in the history
Fix #5777.  Don't warn when applying default style
  • Loading branch information
jenshnielsen committed Jan 5, 2016
2 parents c849398 + c515a9d commit fe701e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions lib/matplotlib/style/core.py
Expand Up @@ -43,13 +43,14 @@
'savefig.directory', 'tk.window_focus', 'hardcopy.docstring'])


def _remove_blacklisted_style_params(d):
def _remove_blacklisted_style_params(d, warn=True):
o = {}
for key, val in d.items():
if key in STYLE_BLACKLIST:
warnings.warn(
"Style includes a parameter, '{0}', that is not related to "
"style. Ignoring".format(key))
if warn:
warnings.warn(
"Style includes a parameter, '{0}', that is not related "
"to style. Ignoring".format(key))
else:
o[key] = val
return o
Expand All @@ -60,8 +61,8 @@ def is_style_file(filename):
return STYLE_FILE_PATTERN.match(filename) is not None


def _apply_style(d):
mpl.rcParams.update(_remove_blacklisted_style_params(d))
def _apply_style(d, warn=True):
mpl.rcParams.update(_remove_blacklisted_style_params(d, warn=warn))


def use(style):
Expand Down Expand Up @@ -98,7 +99,7 @@ def use(style):
if not cbook.is_string_like(style):
_apply_style(style)
elif style == 'default':
_apply_style(rcParamsDefault)
_apply_style(rcParamsDefault, warn=False)
elif style in library:
_apply_style(library[style])
else:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_backend_qt4.py
Expand Up @@ -7,7 +7,7 @@
from matplotlib.testing.decorators import cleanup, switch_backend
from matplotlib.testing.decorators import knownfailureif
from matplotlib._pylab_helpers import Gcf
import matplotlib.style as mstyle
import matplotlib
import copy

try:
Expand All @@ -17,7 +17,7 @@
import mock

try:
with mstyle.context({'backend': 'Qt4Agg'}):
with matplotlib.rc_context(rc={'backend': 'Qt4Agg'}):
from matplotlib.backends.qt_compat import QtCore

from matplotlib.backends.backend_qt4 import (MODIFIER_KEYS,
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_backend_qt5.py
Expand Up @@ -6,7 +6,7 @@
from matplotlib.testing.decorators import cleanup, switch_backend
from matplotlib.testing.decorators import knownfailureif
from matplotlib._pylab_helpers import Gcf
import matplotlib.style as mstyle
import matplotlib
import copy

try:
Expand All @@ -16,7 +16,7 @@
import mock

try:
with mstyle.context({'backend': 'Qt5Agg'}):
with matplotlib.rc_context(rc={'backend': 'Qt5Agg'}):
from matplotlib.backends.qt_compat import QtCore, __version__
from matplotlib.backends.backend_qt5 import (MODIFIER_KEYS,
SUPER, ALT, CTRL, SHIFT)
Expand Down

0 comments on commit fe701e3

Please sign in to comment.