8000 Suppress some more rc deprecation warnings. · matplotlib/matplotlib@0e611f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e611f9

Browse files
committed
Suppress some more rc deprecation warnings.
1 parent 61bb785 commit 0e611f9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

lib/matplotlib/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,21 +1220,33 @@ def rcdefaults():
12201220
Use a specific style file. Call ``style.use('default')`` to restore
12211221
the default style.
12221222
"""
1223-
rcParams.clear()
1224-
rcParams.update(rcParamsDefault)
1223+
# Deprecation warnings were already handled when creating rcParamsDefault,
1224+
# no need to reemit them here.
1225+
with warnings.catch_warnings():
1226+
warnings.simplefilter("ignore", mplDeprecation)
1227+
rcParams.clear()
1228+
rcParams.update(rcParamsDefault)
12251229

12261230

12271231
def rc_file_defaults():
12281232
"""Restore the rc params from the original rc file loaded by Matplotlib.
12291233
"""
1230-
rcParams.update(rcParamsOrig)
1234+
# Deprecation warnings were already handled when creating rcParamsOrig, no
1235+
# need to reemit them here.
1236+
with warnings.catch_warnings():
1237+
warnings.simplefilter("ignore", mplDeprecation)
1238+
rcParams.update(rcParamsOrig)
12311239

12321240

12331241
def rc_file(fname):
12341242
"""
12351243
Update rc params from file.
12361244
"""
1237-
rcParams.update(rc_params_from_file(fname))
1245+
# Deprecation warnings were already handled in rc_params_from_file, no need
1246+
# to reemit them here.
1247+
with warnings.catch_warnings():
1248+
warnings.simplefilter("ignore", mplDeprecation)
1249+
rcParams.update(rc_params_from_file(fname))
12381250

12391251

12401252
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)
0