Skip to content

Commit 265037a

Browse files
committed
Added some comments and removed the uggly break statement
1 parent 1f3e4ed commit 265037a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

proplot/colors.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -2853,12 +2853,27 @@ def _init_cmap_database():
28532853
"""
28542854
Initialize the subclassed database.
28552855
"""
2856+
28562857
# WARNING: Skip over the matplotlib native duplicate entries
28572858
# with suffixes '_r' and '_shifted'.
2858-
for prop in ["_cmap_registry", "cmap_d", "_colormaps"]:
2859-
if hasattr(mcm, prop):
2860-
attr = prop
2861-
break
2859+
def get_correct_register(
2860+
props=[
2861+
"_cmap_registry",
2862+
"cmap_d",
2863+
"_colormaps",
2864+
]
2865+
):
2866+
# In matplotlib.cm as register is made under
2867+
# _colormaps (as of 3.9.1). It seems like they are
2868+
# moving towards using ColormapRegister as a static class
2869+
# so this may change in the future. This piece of code
2870+
# is to ensure that the correct object is used
2871+
# to register proplots colormaps
2872+
for prop in props:
2873+
if hasattr(mcm, prop):
2874+
return prop
2875+
2876+
attr = get_correct_register()
28622877
database = getattr(mcm, attr)
28632878
if mcm.get_cmap is not _get_cmap:
28642879
mcm.get_cmap = _get_cmap

0 commit comments

Comments
 (0)