consistent style
This commit is contained in:
parent
e8d20a8fec
commit
bc667888ce
|
@ -47,27 +47,32 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __eq__(self, other: object) -> bool:
|
def __eq__(self,
|
||||||
|
other: object) -> bool:
|
||||||
"""Test equality of colormaps."""
|
"""Test equality of colormaps."""
|
||||||
if not isinstance(other, Colormap):
|
if not isinstance(other, Colormap):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
return len(self.colors) == len(other.colors) \
|
return len(self.colors) == len(other.colors) \
|
||||||
and bool(np.all(self.colors == other.colors))
|
and bool(np.all(self.colors == other.colors))
|
||||||
|
|
||||||
def __add__(self, other: 'Colormap') -> 'Colormap':
|
def __add__(self,
|
||||||
|
other: 'Colormap') -> 'Colormap':
|
||||||
"""Concatenate."""
|
"""Concatenate."""
|
||||||
return Colormap(np.vstack((self.colors,other.colors)),
|
return Colormap(np.vstack((self.colors,other.colors)),
|
||||||
f'{self.name}+{other.name}')
|
f'{self.name}+{other.name}')
|
||||||
|
|
||||||
def __iadd__(self, other: 'Colormap') -> 'Colormap':
|
def __iadd__(self,
|
||||||
|
other: 'Colormap') -> 'Colormap':
|
||||||
"""Concatenate (in-place)."""
|
"""Concatenate (in-place)."""
|
||||||
return self.__add__(other)
|
return self.__add__(other)
|
||||||
|
|
||||||
def __mul__(self, factor: int) -> 'Colormap':
|
def __mul__(self,
|
||||||
|
factor: int) -> 'Colormap':
|
||||||
"""Repeat."""
|
"""Repeat."""
|
||||||
return Colormap(np.vstack([self.colors]*factor),f'{self.name}*{factor}')
|
return Colormap(np.vstack([self.colors]*factor),f'{self.name}*{factor}')
|
||||||
|
|
||||||
def __imul__(self, factor: int) -> 'Colormap':
|
def __imul__(self,
|
||||||
|
factor: int) -> 'Colormap':
|
||||||
"""Repeat (in-place)."""
|
"""Repeat (in-place)."""
|
||||||
return self.__mul__(factor)
|
return self.__mul__(factor)
|
||||||
|
|
||||||
|
@ -276,7 +281,8 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
mode='RGBA')
|
mode='RGBA')
|
||||||
|
|
||||||
|
|
||||||
def reversed(self, name: str = None) -> 'Colormap':
|
def reversed(self,
|
||||||
|
name: str = None) -> 'Colormap':
|
||||||
"""
|
"""
|
||||||
Reverse.
|
Reverse.
|
||||||
|
|
||||||
|
@ -329,7 +335,8 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
|
|
||||||
def save_paraview(self, fname: FileHandle = None):
|
def save_paraview(self,
|
||||||
|
fname: FileHandle = None):
|
||||||
"""
|
"""
|
||||||
Save as JSON file for use in Paraview.
|
Save as JSON file for use in Paraview.
|
||||||
|
|
||||||
|
@ -356,7 +363,8 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
fhandle.write('\n')
|
fhandle.write('\n')
|
||||||
|
|
||||||
|
|
||||||
def save_ASCII(self, fname: FileHandle = None):
|
def save_ASCII(self,
|
||||||
|
fname: FileHandle = None):
|
||||||
"""
|
"""
|
||||||
Save as ASCII file.
|
Save as ASCII file.
|
||||||
|
|
||||||
|
@ -391,7 +399,8 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
self._get_file_handle(fname,'.legend').write(GOM_str)
|
self._get_file_handle(fname,'.legend').write(GOM_str)
|
||||||
|
|
||||||
|
|
||||||
def save_gmsh(self, fname: FileHandle = None):
|
def save_gmsh(self,
|
||||||
|
fname: FileHandle = None):
|
||||||
"""
|
"""
|
||||||
Save as ASCII file for use in gmsh.
|
Save as ASCII file for use in gmsh.
|
||||||
|
|
||||||
|
@ -622,7 +631,8 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _lab2xyz(lab: np.ndarray, ref_white: np.ndarray = _REF_WHITE) -> np.ndarray:
|
def _lab2xyz(lab: np.ndarray,
|
||||||
|
ref_white: np.ndarray = _REF_WHITE) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
CIE Lab to CIE Xyz.
|
CIE Lab to CIE Xyz.
|
||||||
|
|
||||||
|
@ -653,7 +663,8 @@ class Colormap(mpl.colors.ListedColormap):
|
||||||
])*ref_white
|
])*ref_white
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _xyz2lab(xyz: np.ndarray, ref_white: np.ndarray = _REF_WHITE) -> np.ndarray:
|
def _xyz2lab(xyz: np.ndarray,
|
||||||
|
ref_white: np.ndarray = _REF_WHITE) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
CIE Xyz to CIE Lab.
|
CIE Xyz to CIE Lab.
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,8 @@ class Grid:
|
||||||
copy = __copy__
|
copy = __copy__
|
||||||
|
|
||||||
|
|
||||||
def __eq__(self, other: object) -> bool:
|
def __eq__(self,
|
||||||
|
other: object) -> bool:
|
||||||
"""
|
"""
|
||||||
Test equality of other.
|
Test equality of other.
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,8 @@ class Table:
|
||||||
return labels
|
return labels
|
||||||
|
|
||||||
|
|
||||||
def _relabel(self, how: str):
|
def _relabel(self,
|
||||||
|
how: str):
|
||||||
"""
|
"""
|
||||||
Modify labeling of data in-place.
|
Modify labeling of data in-place.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue