From 0dfefca8f753168a9f53eb06919bd0095e77de3b Mon Sep 17 00:00:00 2001 From: "Kacper Kowalik (Xarthisius)" Date: Sun, 19 Jul 2020 10:07:21 -0500 Subject: [PATCH] Remove a bazillion of MatplotlibDeprecationWarnings --- yt/funcs.py | 10 ++++++---- yt/visualization/base_plot_types.py | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/yt/funcs.py b/yt/funcs.py index c69ff1cfdd7..659b507c42e 100644 --- a/yt/funcs.py +++ b/yt/funcs.py @@ -18,6 +18,7 @@ import urllib.parse import urllib.request import warnings +from distutils.version import LooseVersion from functools import wraps from math import ceil, floor from numbers import Number as numeric_type @@ -1266,10 +1267,11 @@ def matplotlib_style_context(style_name=None, after_reset=False): available, returns a dummy context manager. """ if style_name is None: - style_name = { - "mathtext.fontset": "cm", - "mathtext.fallback_to_cm": True, - } + style_name = {"mathtext.fontset": "cm"} + if LooseVersion(matplotlib.__version__) >= LooseVersion("3.3.0"): + style_name["mathtext.fallback"] = "cm" + else: + style_name["mathtext.fallback_to_cm"] = True try: import matplotlib.style diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py index 4b64ac2f130..4bfc142857a 100644 --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -134,7 +134,9 @@ def save(self, name, mpl_kwargs=None, canvas=None): if mpl_kwargs is None: mpl_kwargs = {} - if "papertype" not in mpl_kwargs: + if "papertype" not in mpl_kwargs and LooseVersion( + matplotlib.__version__ + ) < LooseVersion("3.3.0"): mpl_kwargs["papertype"] = "auto" suffix = get_image_suffix(name)