Skip to content

Commit

Permalink
Merge pull request #2519 from codypiersall/undeprecate_get_colormap
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Aug 31, 2023
2 parents 7456b01 + 43b237b commit 5a35d04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/demo/scene/picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
selected = None

# plot data
cmap = get_colormap('hsl', value=0.5)
cmap = get_colormap('hsl')
colors = cmap.map(np.linspace(0.1, 0.9, data.shape[0]))
t = np.arange(data.shape[1]) * (dt * 1000)
for i, y in enumerate(data):
Expand Down
28 changes: 4 additions & 24 deletions vispy/color/colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,17 +1092,13 @@ def __init__(self, limits=(0.33, 0.66, 1.0)):
)


def get_colormap(name, *args, **kwargs):
"""Obtain a colormap.
def get_colormap(name):
"""Obtain a colormap by name.
Parameters
----------
name : str | Colormap
Colormap name. Can also be a Colormap for pass-through.
*args:
Deprecated.
**kwargs
Deprecated.
Examples
--------
Expand All @@ -1111,33 +1107,17 @@ def get_colormap(name, *args, **kwargs):
.. versionchanged: 0.7
Additional args/kwargs are no longer accepted. Colormap classes are
no longer created on the fly. To create a ``cubehelix``
(``CubeHelixColormap``), ``single_hue`` (``SingleHue``), ``hsl``
(``HSL``), ``husl`` (``HSLuv``), ``diverging`` (``Diverging``), or
``RdYeBuCy`` (``RedYellowBlueCyan``) colormap you must import and
instantiate it directly from the ``vispy.color.colormap`` module.
Additional args/kwargs are no longer accepted. Colormap instances are
no longer created on the fly.
"""
if args or kwargs:
warnings.warn("Creating a Colormap instance with 'get_colormap' is "
"no longer supported. No additional arguments or "
"keyword arguments should be passed.", DeprecationWarning)
if isinstance(name, BaseColormap):
return name

if not isinstance(name, str):
raise TypeError('colormap must be a Colormap or string name')
if name in _colormaps: # vispy cmap
cmap = _colormaps[name]
if name in ("cubehelix", "single_hue", "hsl", "husl", "diverging", "RdYeBuCy"):
warnings.warn(
f"Colormap '{name}' has been deprecated since vispy 0.7. "
f"Please import and create 'vispy.color.colormap.{cmap.__class__.__name__}' "
"directly instead.",
DeprecationWarning,
stacklevel=2,
)

elif has_matplotlib(): # matplotlib cmap
try:
Expand Down

0 comments on commit 5a35d04

Please sign in to comment.