From 83d7b919ec78a0ced908828b41c621096187ef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sat, 18 Feb 2023 23:23:16 +0100 Subject: [PATCH] fixup! fixup! ENH: revive and update yt.funcs.matplotlib_style_context context manager --- yt/funcs.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/yt/funcs.py b/yt/funcs.py index 064e923294b..a69ededf2c2 100644 --- a/yt/funcs.py +++ b/yt/funcs.py @@ -993,11 +993,11 @@ def get_brewer_cmap(cmap): return bmap.get_mpl_colormap(N=cmap[2]) -def matplotlib_style_context(style=None, after_reset=False): +def matplotlib_style_context(style="yt.default", after_reset=False): """Returns a context manager for controlling matplotlib style. Arguments are passed to matplotlib.style.context() if specified. Defaults - to setting "yt.default" style, after resetting to the default config parameters. + to setting yt's "yt.default" style, after resetting to the default config parameters. """ # FUTURE: this function should be deprecated in favour of matplotlib.style.context # after support for matplotlib 3.6 and older versions is dropped. @@ -1005,11 +1005,8 @@ def matplotlib_style_context(style=None, after_reset=False): from yt.visualization._commons import MPL_VERSION - if style is None: - if MPL_VERSION >= Version("3.7"): - style = "yt.default" - else: - style = importlib_resources.files("yt") / "default.mplstyle" + if style == "yt.default" and MPL_VERSION < Version("3.7"): + style = importlib_resources.files("yt") / "default.mplstyle" return matplotlib.style.context(style, after_reset=after_reset)