added __eq__ and test

This commit is contained in:
Philip Eisenlohr 2021-11-23 17:46:38 -05:00
parent 3e1a6dcab7
commit 3bf10127b8
1 changed files with 5 additions and 0 deletions

View File

@ -42,6 +42,11 @@ class Colormap(mpl.colors.ListedColormap):
"""
def __eq__(self, other) -> bool:
"""Test equality of colormaps."""
return len(self.colors) == len(other.colors) \
and bool(np.all(self.colors == other.colors))
def __add__(self, other: "Colormap") -> "Colormap":
"""Concatenate."""
return Colormap(np.vstack((self.colors,other.colors)),