Skip to content

Commit

Permalink
Added some comments and removed the uggly break statement
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanelteren committed Jul 27, 2024
1 parent 1f3e4ed commit 265037a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions proplot/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2853,12 +2853,27 @@ def _init_cmap_database():
"""
Initialize the subclassed database.
"""

# WARNING: Skip over the matplotlib native duplicate entries
# with suffixes '_r' and '_shifted'.
for prop in ["_cmap_registry", "cmap_d", "_colormaps"]:
if hasattr(mcm, prop):
attr = prop
break
def get_correct_register(
props=[
"_cmap_registry",
"cmap_d",
"_colormaps",
]
):
# In matplotlib.cm as register is made under
# _colormaps (as of 3.9.1). It seems like they are
# moving towards using ColormapRegister as a static class
# so this may change in the future. This piece of code
# is to ensure that the correct object is used
# to register proplots colormaps
for prop in props:
if hasattr(mcm, prop):
return prop

attr = get_correct_register()
database = getattr(mcm, attr)
if mcm.get_cmap is not _get_cmap:
mcm.get_cmap = _get_cmap
Expand Down

0 comments on commit 265037a

Please sign in to comment.