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

Skip to content

Commit 9a147a4

Browse files
committed
Suppress some more rc deprecation warnings.
1 parent 99db86c commit 9a147a4

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

lib/matplotlib/__init__.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ def gen_candidates():
820820
'axes.hold': ('2.1',),
821821
'backend.qt4': ('2.2',),
822822
'backend.qt5': ('2.2',),
823-
'text.latex.unicde': ('3.0',),
823+
'text.latex.unicode': ('3.0',),
824824
}
825825

826826

@@ -883,7 +883,7 @@ def __setitem__(self, key, val):
883883
val = alt_val(val)
884884
elif key in _deprecated_remain_as_none and val is not None:
885885
version, = _deprecated_remain_as_none[key]
886-
addendum = None
886+
addendum = ''
887887
if key.startswith('backend'):
888888
addendum = (
889889
"In order to force the use of a specific Qt binding, "
@@ -1243,21 +1243,33 @@ def rcdefaults():
12431243
Use a specific style file. Call ``style.use('default')`` to restore
12441244
the default style.
12451245
"""
1246-
rcParams.clear()
1247-
rcParams.update(rcParamsDefault)
1246+
# Deprecation warnings were already handled when creating rcParamsDefault,
1247+
# no need to reemit them here.
1248+
with warnings.catch_warnings():
1249+
warnings.simplefilter("ignore", mplDeprecation)
1250+
rcParams.clear()
1251+
rcParams.update(rcParamsDefault)
12481252

12491253

12501254
def rc_file_defaults():
12511255
"""Restore the rc params from the original rc file loaded by Matplotlib.
12521256
"""
1253-
rcParams.update(rcParamsOrig)
1257+
# Deprecation warnings were already handled when creating rcParamsOrig, no
1258+
# need to reemit them here.
1259+
with warnings.catch_warnings():
1260+
warnings.simplefilter("ignore", mplDeprecation)
1261+
rcParams.update(rcParamsOrig)
12541262

12551263

12561264
def rc_file(fname):
12571265
"""
12581266
Update rc params from file.
12591267
"""
1260-
rcParams.update(rc_params_from_file(fname))
1268+
# Deprecation warnings were already handled in rc_params_from_file, no need
1269+
# to reemit them here.
1270+
with warnings.catch_warnings():
1271+
warnings.simplefilter("ignore", mplDeprecation)
1272+
rcParams.update(rc_params_from_file(fname))
12611273

12621274

12631275
class rc_context:

lib/matplotlib/style/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import matplotlib as mpl
2020
from matplotlib import rc_params_from_file, rcParamsDefault
21+
from matplotlib.cbook import MatplotlibDeprecationWarning
2122

2223

2324
__all__ = ['use', 'context', 'available', 'library', 'reload_library']
@@ -98,7 +99,11 @@ def use(style):
9899
if not isinstance(style, str):
99100
_apply_style(style)
100101
elif style == 'default':
101-
_apply_style(rcParamsDefault, warn=False)
102+
# Deprecation warnings were already handled when creating
103+
# rcParamsDefault, no need to reemit them here.
104+
with warnings.catch_warnings():
105+
warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
106+
_apply_style(rcParamsDefault, warn=False)
102107
elif style in library:
103108
_apply_style(library[style])
104109
else:

0 commit comments

Comments
 (0)