follow new convention for "shape" and "len" in docstrings

This commit is contained in:
Philip Eisenlohr 2021-12-03 11:07:12 -05:00 committed by Martin Diehl
parent 2a6b37a0e5
commit b57351045b
1 changed files with 36 additions and 40 deletions

View File

@ -29,7 +29,7 @@ class Colormap(mpl.colors.ListedColormap):
Enhance matplotlib colormap functionality to be used within DAMASK. Enhance matplotlib colormap functionality to be used within DAMASK.
Colors are internally stored as R(ed) G(green) B(lue) values. Colors are internally stored as R(ed) G(green) B(lue) values.
The colormap can be used in matplotlib, seaborn, etc., and can The colormap can be used in matplotlib, seaborn, etc., or can
exported to file for external use. exported to file for external use.
References References
@ -72,8 +72,8 @@ class Colormap(mpl.colors.ListedColormap):
ax1.set_axis_off() ax1.set_axis_off()
ax1.imshow(np.linspace(0,1,self.N).reshape(1,-1), ax1.imshow(np.linspace(0,1,self.N).reshape(1,-1),
aspect='auto', cmap=self, interpolation='nearest') aspect='auto', cmap=self, interpolation='nearest')
plt.show(block = False) plt.show(block=False)
return 'Colormap: '+self.name return f'Colormap: {self.name}'
@staticmethod @staticmethod
@ -87,16 +87,16 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
low : iterable of float (3) low : sequence of float, len (3)
Color definition for minimum value. Color definition for minimum value.
high : iterable of float (3) high : sequence of float, len (3)
Color definition for maximum value. Color definition for maximum value.
name : str, optional name : str, optional
Name of the colormap. Defaults to 'DAMASK colormap'. Name of the colormap. Defaults to 'DAMASK colormap'.
N : int, optional N : int, optional
Number of color quantization levels. Defaults to 256. Number of color quantization levels. Defaults to 256.
model : {'rgb', 'hsv', 'hsl', 'xyz', 'lab', 'msh'} model : {'rgb', 'hsv', 'hsl', 'xyz', 'lab', 'msh'}
Color model used for input color definitions. Defaults to `rgb`. Color model used for input color definitions. Defaults to 'rgb'.
The available color models are: The available color models are:
- 'rgb': Red Green Blue. - 'rgb': Red Green Blue.
- 'hsv': Hue Saturation Value. - 'hsv': Hue Saturation Value.
@ -200,9 +200,9 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
field : numpy.array of shape (:,:) field : numpy.array, shape (:,:)
Data to be shaded. Data to be shaded.
bounds : iterable of float (2), optional bounds : sequence of float, len (2), optional
Value range (low,high) spanned by colormap. Value range (low,high) spanned by colormap.
gap : field.dtype, optional gap : field.dtype, optional
Transparent value. NaN will always be rendered transparent. Transparent value. NaN will always be rendered transparent.
@ -261,18 +261,18 @@ class Colormap(mpl.colors.ListedColormap):
def _get_file_handle(self, def _get_file_handle(self,
fname: Union[TextIO, str, Path, None], fname: Union[TextIO, str, Path, None],
suffix: str = '') -> TextIO: suffix: str = '') -> TextIO:
""" """
Provide file handle. Provide file handle.
Parameters Parameters
---------- ----------
fname : file, str, pathlib.Path, or None fname : file, str, pathlib.Path, or None
Filename or file handle. Name or handle of file.
If None, colormap name + suffix. If None, colormap name + suffix.
suffix: str, optional suffix: str, optional
Extension to use for colormap filename. Extension to use for colormap file.
Returns Returns
------- -------
@ -295,8 +295,7 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
fname : file, str, or pathlib.Path, optional fname : file, str, or pathlib.Path, optional
Filename to store results. If not given, the filename will File to store results. Defaults to colormap name + '.json'.
consist of the name of the colormap with extension '.json'.
""" """
colors = [] colors = []
@ -323,8 +322,7 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
fname : file, str, or pathlib.Path, optional fname : file, str, or pathlib.Path, optional
Filename to store results. If not given, the filename will File to store results. Defaults to colormap name + '.txt'.
consist of the name of the colormap with extension '.txt'.
""" """
labels = {'RGBA':4} if self.colors.shape[1] == 4 else {'RGB': 3} labels = {'RGBA':4} if self.colors.shape[1] == 4 else {'RGB': 3}
@ -339,8 +337,7 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
fname : file, str, or pathlib.Path, optional fname : file, str, or pathlib.Path, optional
Filename to store results. If not given, the filename will File to store results. Defaults to colormap name + '.legend'.
consist of the name of the colormap with extension '.legend'.
""" """
# ToDo: test in GOM # ToDo: test in GOM
@ -360,8 +357,7 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
fname : file, str, or pathlib.Path, optional fname : file, str, or pathlib.Path, optional
Filename to store results. If not given, the filename will File to store results. Defaults to colormap name + '.msh'.
consist of the name of the colormap with extension '.msh'.
""" """
# ToDo: test in gmsh # ToDo: test in gmsh
@ -457,12 +453,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
hsv : numpy.ndarray of shape (3) hsv : numpy.ndarray, shape (3)
HSV values. HSV values.
Returns Returns
------- -------
rgb : numpy.ndarray of shape (3) rgb : numpy.ndarray, shape (3)
RGB values. RGB values.
""" """
@ -475,12 +471,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
rgb : numpy.ndarray of shape (3) rgb : numpy.ndarray, shape (3)
RGB values. RGB values.
Returns Returns
------- -------
hsv : numpy.ndarray of shape (3) hsv : numpy.ndarray, shape (3)
HSV values. HSV values.
""" """
@ -495,12 +491,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
hsl : numpy.ndarray of shape (3) hsl : numpy.ndarray, shape (3)
HSL values. HSL values.
Returns Returns
------- -------
rgb : numpy.ndarray of shape (3) rgb : numpy.ndarray, shape (3)
RGB values. RGB values.
""" """
@ -513,12 +509,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
rgb : numpy.ndarray of shape (3) rgb : numpy.ndarray, shape (3)
RGB values. RGB values.
Returns Returns
------- -------
hsl : numpy.ndarray of shape (3) hsl : numpy.ndarray, shape (3)
HSL values. HSL values.
""" """
@ -533,12 +529,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
xyz : numpy.ndarray of shape (3) xyz : numpy.ndarray, shape (3)
CIE Xyz values. CIE Xyz values.
Returns Returns
------- -------
rgb : numpy.ndarray of shape (3) rgb : numpy.ndarray, shape (3)
RGB values. RGB values.
References References
@ -563,12 +559,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
rgb : numpy.ndarray of shape (3) rgb : numpy.ndarray, shape (3)
RGB values. RGB values.
Returns Returns
------- -------
xyz : numpy.ndarray of shape (3) xyz : numpy.ndarray, shape (3)
CIE Xyz values. CIE Xyz values.
References References
@ -591,12 +587,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
lab : numpy.ndarray of shape (3) lab : numpy.ndarray, shape (3)
CIE lab values. CIE lab values.
Returns Returns
------- -------
xyz : numpy.ndarray of shape (3) xyz : numpy.ndarray, shape (3)
CIE Xyz values. CIE Xyz values.
References References
@ -620,12 +616,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
xyz : numpy.ndarray of shape (3) xyz : numpy.ndarray, shape (3)
CIE Xyz values. CIE Xyz values.
Returns Returns
------- -------
lab : numpy.ndarray of shape (3) lab : numpy.ndarray, shape (3)
CIE lab values. CIE lab values.
References References
@ -650,12 +646,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
lab : numpy.ndarray of shape (3) lab : numpy.ndarray, shape (3)
CIE lab values. CIE lab values.
Returns Returns
------- -------
msh : numpy.ndarray of shape (3) msh : numpy.ndarray, shape (3)
Msh values. Msh values.
References References
@ -678,12 +674,12 @@ class Colormap(mpl.colors.ListedColormap):
Parameters Parameters
---------- ----------
msh : numpy.ndarray of shape (3) msh : numpy.ndarray, shape (3)
Msh values. Msh values.
Returns Returns
------- -------
lab : numpy.ndarray of shape (3) lab : numpy.ndarray, shape (3)
CIE lab values. CIE lab values.
References References