-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Description
ALL software version info
colorcet 3.0.1 arviz 0.12.1 python 3.10/8 matplotlib 3.6.0/1
afaik introduced with recent colorcet/matplotlib release
Description of expected behavior and the observed behavior
When multiple libraries use mpl.colormaps.register(cmap, name=cmap_name)
with the same cmap_name
, a ValueError: A colormap named "cet_gray" is already registered.
is raised. This happens e.g. for colorcet + arviz, both of which define cet_gray (see here for arviz).
What is the desired behavior -- does colorcet want to assume control of that color name, preventing others from accidentally overriding it (in which case arviz, which intends to duplicate the colorcet color, would be responsible)? Or should simultaneous overriding of the global variable be allowed.
Complete, minimal, self-contained example code that reproduces the issue
import arviz
import colorcet
or
import colorcet
import arviz
This prohibits the use of both simultaneously.
Stack traceback and/or browser JavaScript console output
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/yannik/env/env/lib/python3.10/site-packages/arviz/__init__.py", line 320, in <module>
_mpl_cm("gray", _linear_grey_10_95_c0)
File "/home/yannik/env/env/lib/python3.10/site-packages/arviz/__init__.py", line 317, in _mpl_cm
register_cmap("cet_" + name, cmap=cmap)
File "/home/yannik/env/env/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 200, in wrapper
return func(*args, **kwargs)
File "/home/yannik/env/env/lib/python3.10/site-packages/matplotlib/cm.py", line 248, in register_cmap
_colormaps.register(cmap, name=name, force=override_builtin)
File "/home/yannik/env/env/lib/python3.10/site-packages/matplotlib/cm.py", line 149, in register
raise ValueError(
ValueError: A colormap named "cet_gray" is already registered.
Metadata
Metadata
Assignees
Labels
No labels