Skip to content

Colormaps having odd naming when converted internally #84

Closed
@cvanelteren

Description

@cvanelteren

Colormaps are converted internally and renamed. This caused a bug in #82 but is recently fixed in main. The issue can be seen from

import ultraplot as plt
for name, cmap in plt.colormaps.items():
    print(f"{cmap.name=} {name=}")
# prints  for example cmap.name='_BR_copy' name='br'

The name of the colormaps if correct, and hence all the functions work correctly. I have the intuition by integration mpl's colormaps and ultraplot's colormaps that this renaming is performed to avoid potential naming collision. I believe this would be unnecessary and is rather confusing.

The relevant code can be found in colors.py

 def _make_name(self, suffix=None):
        """
        Generate a default colormap name. Do not append more than one
        leading underscore or more than one identical suffix.
        """
        name = self.name
        name = name or ""
        if name[:1] != "_":
            name = "_" + name
        suffix = suffix or "copy"
        suffix = "_" + suffix
        if name[-len(suffix) :] != suffix:
            name = name + suffix
        return name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions