From b4e8c056e020122b361cc1a556686d459c572f0f Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Sun, 26 Apr 2020 19:04:53 -0700 Subject: [PATCH] Eat matplotlib deprecation warning matplotlib is issuing a deprecation warning whenever you use rcParams, even if you are not using one of the deprecated values. This is very annoying. I eat the deprecation while using rcParams. https://github.com/matplotlib/matplotlib/issues/13118 --- book_format.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/book_format.py b/book_format.py index 3b2935b..4bbb8ea 100644 --- a/book_format.py +++ b/book_format.py @@ -58,7 +58,9 @@ def test_filterpy_version(): # chapter so the reader can see that they need to update FilterPy. test_filterpy_version() -pylab.rcParams['figure.max_open_warning'] = 50 +with warnings.catch_warnings(): + warnings.simplefilter("ignore", matplotlib.MatplotlibDeprecationWarning) + pylab.rcParams['figure.max_open_warning'] = 50 @contextmanager @@ -110,7 +112,10 @@ def set_style(): style = json.load(open("./kf_book/538.json")) else: style = json.load(open(".//kf_book/538.json"), object_hook=_decode_dict) - plt.rcParams.update(style) + + with warnings.catch_warnings(): + warnings.simplefilter("ignore", matplotlib.MatplotlibDeprecationWarning) + plt.rcParams.update(style) except: pass np.set_printoptions(suppress=True, precision=3,