FIX: Update the colormap object's name when registering · matplotlib/matplotlib@e327961 · GitHub
Skip to content

Commit e327961

Browse files
committed
FIX: Update the colormap object's name when registering
When registering a colormap you can use a different name than the "cmap.name" attribute now. This will set the colormap based on the registered name rather than cmap.name, updating the copy of the object that gets registered. Additionally, the equals method of Colormaps shouldn't care about the name of the object, we should only worry about whether the values are the same in the lookup tables and let someone use object identity if they are worried about the name of the object.
1 parent 1d1d8ba commit e327961

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

lib/matplotlib/cm.py

Lines changed: 5 additions & 0 deletions

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def __copy__(self):
774774
return cmapobject
775775

776776
def __eq__(self, other):
777-
if (not isinstance(other, Colormap) or self.name != other.name or
777+
if (not isinstance(other, Colormap) or
778778
self.colorbar_extend != other.colorbar_extend):
779779
return False
780780
# To compare lookup tables the Colormaps have to be initialized

lib/matplotlib/tests/test_colors.py

Lines changed: 12 additions & 4 deletions

0 commit comments

Comments
 (0)