From 3bf10127b84d8b9095ae32bb36ef072aa5b93485 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Nov 2021 17:46:38 -0500 Subject: [PATCH] added __eq__ and test --- python/damask/_colormap.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index d975aecd4..3759ebe86 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -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)),