simplified

This commit is contained in:
Martin Diehl 2022-01-24 15:07:47 +01:00
parent 6bd23715b8
commit 7c72bd48fb
1 changed files with 1 additions and 3 deletions

View File

@ -65,9 +65,7 @@ class Colormap(mpl.colors.ListedColormap):
def __mul__(self, factor: int) -> 'Colormap': def __mul__(self, factor: int) -> 'Colormap':
"""Repeat.""" """Repeat."""
return Colormap(np.broadcast_to(self.colors,(factor,)+self.colors.shape) return Colormap(np.vstack([self.colors]*factor),f'{self.name}*{factor}')
.reshape((factor*self.colors.shape[0],)+self.colors.shape[1:]),
f'{self.name}*{factor}')
def __imul__(self, factor: int) -> 'Colormap': def __imul__(self, factor: int) -> 'Colormap':
"""Repeat (in-place).""" """Repeat (in-place)."""