From 792e8a33cde3107453e1ba82f60a4b7fef7fbfa2 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 7 Jun 2024 17:34:54 +0200 Subject: [PATCH 1/2] Don't use deprecated matplotlib.cm.get_cmap. pyplot.get_cmap provides the desired API and is compatible across all versions of matplotlib. --- yt_idv/opengl_support.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yt_idv/opengl_support.py b/yt_idv/opengl_support.py index 0d37647..71219e7 100644 --- a/yt_idv/opengl_support.py +++ b/yt_idv/opengl_support.py @@ -18,7 +18,7 @@ import numpy as np import traitlets import traittypes -from matplotlib import colormaps as cm +import matplotlib.pyplot as plt from OpenGL import GL # Set up a mapping from numbers to names @@ -221,7 +221,7 @@ def __init__(self, *args, **kwargs): @traitlets.validate("colormap_name") def _validate_name(self, proposal): try: - cm.get_cmap(proposal["value"]) + plt.get_cmap(proposal["value"]) except ValueError: raise traitlets.TraitError( "Colormap name needs to be known by" "matplotlib" @@ -230,7 +230,7 @@ def _validate_name(self, proposal): @traitlets.observe("colormap_name") def _observe_colormap_name(self, change): - cmap = cm.get_cmap(change["new"]) + cmap = plt.get_cmap(change["new"]) cmap_vals = np.array(cmap(np.linspace(0, 1, 256)), dtype="f4") self.data = cmap_vals From 2f9cbb32493056c81cac24772750ddc1cf1ba8db Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:37:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- yt_idv/opengl_support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_idv/opengl_support.py b/yt_idv/opengl_support.py index 71219e7..06d5a2d 100644 --- a/yt_idv/opengl_support.py +++ b/yt_idv/opengl_support.py @@ -15,10 +15,10 @@ from contextlib import ExitStack, contextmanager +import matplotlib.pyplot as plt import numpy as np import traitlets import traittypes -import matplotlib.pyplot as plt from OpenGL import GL # Set up a mapping from numbers to names