From 3e1a6dcab730570f41174cca6972fb97e256ab38 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Nov 2021 17:20:07 -0500 Subject: [PATCH 1/6] polished help; streamlined from_range() --- python/damask/_colormap.py | 114 ++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 5032d6b18..d975aecd4 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -81,20 +81,20 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- - low : numpy.ndarray of shape (3) + low : iterable of float (3) Color definition for minimum value. - high : numpy.ndarray of shape (3) + high : iterable of float (3) Color definition for maximum value. - N : int, optional - The number of color quantization levels. Defaults to 256. name : str, optional - The name of the colormap. Defaults to `DAMASK colormap`. + Name of the colormap. Defaults to `DAMASK colormap`. + N : int, optional + Number of color quantization levels. Defaults to 256. model : {'rgb', 'hsv', 'hsl', 'xyz', 'lab', 'msh'} Colormodel used for input color definitions. Defaults to `rgb`. The available color models are: - - 'rgb': R(ed) G(green) B(lue). - - 'hsv': H(ue) S(aturation) V(alue). - - 'hsl': H(ue) S(aturation) L(uminance). + - 'rgb': Red Green Blue. + - 'hsv': Hue Saturation Value. + - 'hsl': Hue Saturation Luminance. - 'xyz': CIE Xyz. - 'lab': CIE Lab. - 'msh': Msh (for perceptual uniform interpolation). @@ -110,41 +110,34 @@ class Colormap(mpl.colors.ListedColormap): >>> damask.Colormap.from_range((0,0,1),(0,0,0),'blue_to_black') """ - low_high = np.vstack((low,high)) - if model.lower() == 'rgb': - if np.any(low_high<0) or np.any(low_high>1): - raise ValueError(f'RGB color {low} | {high} are out of range.') + toMsh = dict( + rgb=Colormap._rgb2msh, + hsv=Colormap._hsv2msh, + hsl=Colormap._hsl2msh, + xyz=Colormap._xyz2msh, + lab=Colormap._lab2msh, + msh=lambda x:x, + ) - low_,high_ = map(Colormap._rgb2msh,low_high) - - elif model.lower() == 'hsv': - if np.any(low_high<0) or np.any(low_high>[360,1,1]): - raise ValueError(f'HSV color {low} | {high} are out of range.') - - low_,high_ = map(Colormap._hsv2msh,low_high) - - elif model.lower() == 'hsl': - if np.any(low_high<0) or np.any(low_high>[360,1,1]): - raise ValueError(f'HSL color {low} | {high} are out of range.') - - low_,high_ = map(Colormap._hsl2msh,low_high) - - elif model.lower() == 'xyz': - - low_,high_ = map(Colormap._xyz2msh,low_high) - - elif model.lower() == 'lab': - if np.any(low_high[:,0]<0): - raise ValueError(f'CIE Lab color {low} | {high} are out of range.') - - low_,high_ = map(Colormap._lab2msh,low_high) - - elif model.lower() == 'msh': - low_,high_ = low_high[0],low_high[1] - - else: + if model.lower() not in toMsh: raise ValueError(f'Invalid color model: {model}.') + low_high = np.vstack((low,high)) + outofbounds = np.bool_(False) + + if model.lower() == 'rgb': + outofbounds = np.any(low_high<0) or np.any(low_high>1) + elif model.lower() == 'hsv': + outofbounds = np.any(low_high<0) or np.any(low_high>[360,1,1]) + elif model.lower() == 'hsl': + outofbounds = np.any(low_high<0) or np.any(low_high>[360,1,1]) + elif model.lower() == 'lab': + outofbounds = np.any(low_high[:,0]<0) + + if outofbounds: + raise ValueError(f'{model.upper()} colors {low} | {high} are out of bounds.') + + low_,high_ = map(toMsh[model.lower()],low_high) msh = map(functools.partial(Colormap._interpolate_msh,low=low_,high=high_),np.linspace(0,1,N)) rgb = np.array(list(map(Colormap._msh2rgb,msh))) @@ -162,9 +155,9 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- name : str - The name of the colormap. + Name of the colormap. N : int, optional - The number of color quantization levels. Defaults to 256. + Number of color quantization levels. Defaults to 256. This parameter is not used for matplotlib colormaps that are of type `ListedColormap`. @@ -179,8 +172,8 @@ class Colormap(mpl.colors.ListedColormap): >>> damask.Colormap.from_predefined('strain') """ - # matplotlib presets try: + # matplotlib presets colormap = cm.__dict__[name] return Colormap(np.array(list(map(colormap,np.linspace(0,1,N))) if isinstance(colormap,mpl.colors.LinearSegmentedColormap) else @@ -203,8 +196,8 @@ class Colormap(mpl.colors.ListedColormap): ---------- field : numpy.array of shape (:,:) Data to be shaded. - bounds : iterable of len (2), optional - Colormap value range (low,high). + bounds : iterable of float (2), optional + Value range (low,high) to shade with colormap. gap : field.dtype, optional Transparent value. NaN will always be rendered transparent. @@ -243,13 +236,13 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- name : str, optional - The name for the reversed colormap. + Name for the reversed colormap. A name of None will be replaced by the name of the parent colormap + "_r". Returns ------- damask.Colormap - The reversed colormap. + Reversed colormap. Examples -------- @@ -268,7 +261,8 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- fname : file, str, pathlib.Path, or None - Filename or filehandle, will be name of the colormap+extension if None. + Filename or filehandle. + If None, built from colormap name and ext. ext: str Extension of the filename. @@ -279,7 +273,7 @@ class Colormap(mpl.colors.ListedColormap): """ if fname is None: - return open(self.name.replace(' ','_')+'.'+ext, 'w', newline='\n') + return open(self.name.replace(' ','_')+(ext if ext.startswith('.') else '.'+ext), 'w', newline='\n') elif isinstance(fname, (str, Path)): return open(fname, 'w', newline='\n') else: @@ -294,7 +288,7 @@ class Colormap(mpl.colors.ListedColormap): ---------- fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will - consist of the name of the colormap and extension '.json'. + consist of the name of the colormap with extension '.json'. """ colors: List = [] @@ -320,7 +314,7 @@ class Colormap(mpl.colors.ListedColormap): ---------- fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will - consist of the name of the colormap and extension '.txt'. + consist of the name of the colormap with extension '.txt'. """ labels = {'RGBA':4} if self.colors.shape[1] == 4 else {'RGB': 3} @@ -336,7 +330,7 @@ class Colormap(mpl.colors.ListedColormap): ---------- fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will - consist of the name of the colormap and extension '.legend'. + consist of the name of the colormap with extension '.legend'. """ # ToDo: test in GOM @@ -357,7 +351,7 @@ class Colormap(mpl.colors.ListedColormap): ---------- fname : file, str, or pathlib.Path, optional Filename to store results. If not given, the filename will - consist of the name of the colormap and extension '.msh'. + consist of the name of the colormap with extension '.msh'. """ # ToDo: test in gmsh @@ -368,7 +362,7 @@ class Colormap(mpl.colors.ListedColormap): @staticmethod - def _interpolate_msh(frac, + def _interpolate_msh(frac: Union[float,int], low: np.ndarray, high: np.ndarray) -> np.ndarray: """ @@ -448,24 +442,24 @@ class Colormap(mpl.colors.ListedColormap): @staticmethod def _hsv2rgb(hsv: np.ndarray) -> np.ndarray: - """H(ue) S(aturation) V(alue) to R(red) G(reen) B(lue).""" + """Hue Saturation Value to Red Green Blue.""" return np.array(colorsys.hsv_to_rgb(hsv[0]/360.,hsv[1],hsv[2])) @staticmethod def _rgb2hsv(rgb: np.ndarray) -> np.ndarray: - """R(ed) G(reen) B(lue) to H(ue) S(aturation) V(alue).""" + """Red Green Blue to Hue Saturation Value.""" h,s,v = colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]) return np.array([h*360,s,v]) @staticmethod def _hsl2rgb(hsl: np.ndarray) -> np.ndarray: - """H(ue) S(aturation) L(uminance) to R(red) G(reen) B(lue).""" + """Hue Saturation Luminance to Red Green Blue.""" return np.array(colorsys.hls_to_rgb(hsl[0]/360.,hsl[2],hsl[1])) @staticmethod def _rgb2hsl(rgb: np.ndarray) -> np.ndarray: - """R(ed) G(reen) B(lue) to H(ue) S(aturation) L(uminance).""" + """Red Green Blue to Hue Saturation Luminance.""" h,l,s = colorsys.rgb_to_hls(rgb[0],rgb[1],rgb[2]) return np.array([h*360,s,l]) @@ -473,7 +467,7 @@ class Colormap(mpl.colors.ListedColormap): @staticmethod def _xyz2rgb(xyz: np.ndarray) -> np.ndarray: """ - CIE Xyz to R(ed) G(reen) B(lue). + CIE Xyz to Red Green Blue. References ---------- @@ -493,7 +487,7 @@ class Colormap(mpl.colors.ListedColormap): @staticmethod def _rgb2xyz(rgb: np.ndarray) -> np.ndarray: """ - R(ed) G(reen) B(lue) to CIE Xyz. + Red Green Blue to CIE Xyz. References ---------- From 3bf10127b84d8b9095ae32bb36ef072aa5b93485 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 23 Nov 2021 17:46:38 -0500 Subject: [PATCH 2/6] 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)), From bd908dc42507cdb16afb96d2dbd210de4ffef27e Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 25 Nov 2021 13:14:34 -0500 Subject: [PATCH 3/6] test __eq__; polish help strings --- python/damask/_colormap.py | 36 ++++++++++++++++++----------------- python/tests/test_Colormap.py | 9 ++++++--- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 3759ebe86..8f9d49632 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -80,7 +80,7 @@ class Colormap(mpl.colors.ListedColormap): """ Create a perceptually uniform colormap between given (inclusive) bounds. - Colors are internally stored as R(ed) G(green) B(lue) values. + Colors are internally stored as RGB (Red Green Blue) values. The colormap can be used in matplotlib/seaborn or exported to file for external use. @@ -154,8 +154,8 @@ class Colormap(mpl.colors.ListedColormap): """ Select from a set of predefined colormaps. - Predefined colormaps include native matplotlib colormaps - and common DAMASK colormaps. + Predefined colormaps (Colormap.predefined) include + native matplotlib colormaps and common DAMASK colormaps. Parameters ---------- @@ -202,7 +202,7 @@ class Colormap(mpl.colors.ListedColormap): field : numpy.array of shape (:,:) Data to be shaded. bounds : iterable of float (2), optional - Value range (low,high) to shade with colormap. + Value range (low,high) spanned by colormap. gap : field.dtype, optional Transparent value. NaN will always be rendered transparent. @@ -241,8 +241,8 @@ class Colormap(mpl.colors.ListedColormap): Parameters ---------- name : str, optional - Name for the reversed colormap. - A name of None will be replaced by the name of the parent colormap + "_r". + Name of the reversed colormap. + If None, parent colormap name + "_r". Returns ------- @@ -259,26 +259,28 @@ class Colormap(mpl.colors.ListedColormap): return Colormap(np.array(rev.colors),rev.name[:-4] if rev.name.endswith('_r_r') else rev.name) - def _get_file_handle(self, fname: Union[TextIO, str, Path, None], ext: str) -> TextIO: + def _get_file_handle(self, + fname: Union[TextIO, str, Path, None] = None, + suffix: str = None) -> TextIO: """ - Provide file handle. + Provide filehandle. Parameters ---------- fname : file, str, pathlib.Path, or None Filename or filehandle. - If None, built from colormap name and ext. - ext: str - Extension of the filename. + If None, colormap name + suffix. + suffix: str, optional + Extension to use for colormap filename. Returns ------- f : file object - File handle with write access. + Filehandle with write access. """ if fname is None: - return open(self.name.replace(' ','_')+(ext if ext.startswith('.') else '.'+ext), 'w', newline='\n') + return open(self.name.replace(' ','_')+suffix, 'w', newline='\n') elif isinstance(fname, (str, Path)): return open(fname, 'w', newline='\n') else: @@ -308,7 +310,7 @@ class Colormap(mpl.colors.ListedColormap): 'RGBPoints':colors }] - json.dump(out,self._get_file_handle(fname,'json'),indent=4) + json.dump(out,self._get_file_handle(fname,'.json'),indent=4) def save_ASCII(self, fname: Union[TextIO, str, Path] = None): @@ -324,7 +326,7 @@ class Colormap(mpl.colors.ListedColormap): """ labels = {'RGBA':4} if self.colors.shape[1] == 4 else {'RGB': 3} t = Table(self.colors,labels,f'Creator: {util.execution_stamp("Colormap")}') - t.save(self._get_file_handle(fname,'txt')) + t.save(self._get_file_handle(fname,'.txt')) def save_GOM(self, fname: Union[TextIO, str, Path] = None): @@ -345,7 +347,7 @@ class Colormap(mpl.colors.ListedColormap): + ' '.join([f' 0 {c[0]} {c[1]} {c[2]} 255 1' for c in reversed((self.colors*255).astype(int))]) \ + '\n' - self._get_file_handle(fname,'legend').write(GOM_str) + self._get_file_handle(fname,'.legend').write(GOM_str) def save_gmsh(self, fname: Union[TextIO, str, Path] = None): @@ -363,7 +365,7 @@ class Colormap(mpl.colors.ListedColormap): gmsh_str = 'View.ColorTable = {\n' \ +'\n'.join([f'{c[0]},{c[1]},{c[2]},' for c in self.colors[:,:3]*255]) \ +'\n}\n' - self._get_file_handle(fname,'msh').write(gmsh_str) + self._get_file_handle(fname,'.msh').write(gmsh_str) @staticmethod diff --git a/python/tests/test_Colormap.py b/python/tests/test_Colormap.py index 342165134..ab9bcf92f 100644 --- a/python/tests/test_Colormap.py +++ b/python/tests/test_Colormap.py @@ -77,12 +77,15 @@ class TestColormap: # xyz2msh assert np.allclose(Colormap._xyz2msh(xyz),msh,atol=1.e-6,rtol=0) + def test_eq(self): + assert Colormap.from_predefined('strain') == Colormap.from_predefined('strain') + assert Colormap.from_predefined('strain') != Colormap.from_predefined('stress') + assert Colormap.from_predefined('strain',N=128) != Colormap.from_predefined('strain',N=64) + @pytest.mark.parametrize('low,high',[((0,0,0),(1,1,1)), ([0,0,0],[1,1,1])]) def test_from_range_types(self,low,high): - a = Colormap.from_range(low,high) - b = Colormap.from_range(np.array(low),np.array(high)) - assert np.all(a.colors == b.colors) + assert Colormap.from_range(low,high) == Colormap.from_range(np.array(low),np.array(high)) @pytest.mark.parametrize('format',['ASCII','paraview','GOM','gmsh']) @pytest.mark.parametrize('model',['rgb','hsv','hsl','xyz','lab','msh']) From 4ba7c9e67096fd2f41a667010327b1d2c8878afc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 25 Nov 2021 21:22:52 +0100 Subject: [PATCH 4/6] polishing casting numpy.bool_ to bool is a little bit annoying. Mabye using Union[bool, np.bool_] is the better solution, it does not require any changes to the actual code and there is some hope that it will get fixed in mypy https://github.com/numpy/numpy/issues/18876 --- python/damask/_colormap.py | 150 ++++++++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 19 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 8f9d49632..8f694ad45 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -3,7 +3,7 @@ import json import functools import colorsys from pathlib import Path -from typing import Sequence, Union, List, TextIO +from typing import Sequence, Union, TextIO import numpy as np @@ -128,18 +128,18 @@ class Colormap(mpl.colors.ListedColormap): raise ValueError(f'Invalid color model: {model}.') low_high = np.vstack((low,high)) - outofbounds = np.bool_(False) + out_of_bounds = np.bool_(False) if model.lower() == 'rgb': - outofbounds = np.any(low_high<0) or np.any(low_high>1) + out_of_bounds = np.any(low_high<0) or np.any(low_high>1) elif model.lower() == 'hsv': - outofbounds = np.any(low_high<0) or np.any(low_high>[360,1,1]) + out_of_bounds = np.any(low_high<0) or np.any(low_high>[360,1,1]) elif model.lower() == 'hsl': - outofbounds = np.any(low_high<0) or np.any(low_high>[360,1,1]) + out_of_bounds = np.any(low_high<0) or np.any(low_high>[360,1,1]) elif model.lower() == 'lab': - outofbounds = np.any(low_high[:,0]<0) + out_of_bounds = np.any(low_high[:,0]<0) - if outofbounds: + if out_of_bounds: raise ValueError(f'{model.upper()} colors {low} | {high} are out of bounds.') low_,high_ = map(toMsh[model.lower()],low_high) @@ -162,9 +162,9 @@ class Colormap(mpl.colors.ListedColormap): name : str Name of the colormap. N : int, optional - Number of color quantization levels. Defaults to 256. - This parameter is not used for matplotlib colormaps - that are of type `ListedColormap`. + Number of color quantization levels. Defaults to 256. + This parameter is not used for matplotlib colormaps + that are of type `ListedColormap`. Returns ------- @@ -260,8 +260,8 @@ class Colormap(mpl.colors.ListedColormap): def _get_file_handle(self, - fname: Union[TextIO, str, Path, None] = None, - suffix: str = None) -> TextIO: + fname: Union[TextIO, str, Path, None], + suffix: str) -> TextIO: """ Provide filehandle. @@ -270,7 +270,7 @@ class Colormap(mpl.colors.ListedColormap): fname : file, str, pathlib.Path, or None Filename or filehandle. If None, colormap name + suffix. - suffix: str, optional + suffix: str Extension to use for colormap filename. Returns @@ -298,7 +298,7 @@ class Colormap(mpl.colors.ListedColormap): consist of the name of the colormap with extension '.json'. """ - colors: List = [] + colors = [] for i,c in enumerate(np.round(self.colors,6).tolist()): colors+=[i]+c @@ -369,7 +369,7 @@ class Colormap(mpl.colors.ListedColormap): @staticmethod - def _interpolate_msh(frac: Union[float,int], + def _interpolate_msh(frac: float, low: np.ndarray, high: np.ndarray) -> np.ndarray: """ @@ -449,24 +449,76 @@ class Colormap(mpl.colors.ListedColormap): @staticmethod def _hsv2rgb(hsv: np.ndarray) -> np.ndarray: - """Hue Saturation Value to Red Green Blue.""" + """ + Hue Saturation Value to Red Green Blue. + + Parameters + ---------- + hsv : numpy.ndarray of shape (3) + HSV values. + + Returns + ------- + rgb : numpy.ndarray of shape (3) + RGB values. + + """ return np.array(colorsys.hsv_to_rgb(hsv[0]/360.,hsv[1],hsv[2])) @staticmethod def _rgb2hsv(rgb: np.ndarray) -> np.ndarray: - """Red Green Blue to Hue Saturation Value.""" + """ + Red Green Blue to Hue Saturation Value. + + Parameters + ---------- + rgb : numpy.ndarray of shape (3) + RGB values. + + Returns + ------- + hsv : numpy.ndarray of shape (3) + HSV values. + + """ h,s,v = colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]) return np.array([h*360,s,v]) @staticmethod def _hsl2rgb(hsl: np.ndarray) -> np.ndarray: - """Hue Saturation Luminance to Red Green Blue.""" + """ + Hue Saturation Luminance to Red Green Blue. + + Parameters + ---------- + hsl : numpy.ndarray of shape (3) + HSL values. + + Returns + ------- + rgb : numpy.ndarray of shape (3) + RGB values. + + """ return np.array(colorsys.hls_to_rgb(hsl[0]/360.,hsl[2],hsl[1])) @staticmethod def _rgb2hsl(rgb: np.ndarray) -> np.ndarray: - """Red Green Blue to Hue Saturation Luminance.""" + """ + Red Green Blue to Hue Saturation Luminance. + + Parameters + ---------- + rgb : numpy.ndarray of shape (3) + RGB values. + + Returns + ------- + hsl : numpy.ndarray of shape (3) + HSL values. + + """ h,l,s = colorsys.rgb_to_hls(rgb[0],rgb[1],rgb[2]) return np.array([h*360,s,l]) @@ -476,6 +528,16 @@ class Colormap(mpl.colors.ListedColormap): """ CIE Xyz to Red Green Blue. + Parameters + ---------- + xyz : numpy.ndarray of shape (3) + CIE Xyz values. + + Returns + ------- + rgb : numpy.ndarray of shape (3) + RGB values. + References ---------- https://www.easyrgb.com/en/math.php @@ -496,6 +558,16 @@ class Colormap(mpl.colors.ListedColormap): """ Red Green Blue to CIE Xyz. + Parameters + ---------- + rgb : numpy.ndarray of shape (3) + RGB values. + + Returns + ------- + xyz : numpy.ndarray of shape (3) + CIE Xyz values. + References ---------- https://www.easyrgb.com/en/math.php @@ -514,6 +586,16 @@ class Colormap(mpl.colors.ListedColormap): """ CIE Lab to CIE Xyz. + Parameters + ---------- + lab : numpy.ndarray of shape (3) + CIE lab values. + + Returns + ------- + xyz : numpy.ndarray of shape (3) + CIE Xyz values. + References ---------- http://www.brucelindbloom.com/index.html?Eqn_Lab_to_XYZ.html @@ -533,6 +615,16 @@ class Colormap(mpl.colors.ListedColormap): """ CIE Xyz to CIE Lab. + Parameters + ---------- + xyz : numpy.ndarray of shape (3) + CIE Xyz values. + + Returns + ------- + lab : numpy.ndarray of shape (3) + CIE lab values. + References ---------- http://www.brucelindbloom.com/index.html?Eqn_Lab_to_XYZ.html @@ -553,6 +645,16 @@ class Colormap(mpl.colors.ListedColormap): """ CIE Lab to Msh. + Parameters + ---------- + lab : numpy.ndarray of shape (3) + CIE lab values. + + Returns + ------- + msh : numpy.ndarray of shape (3) + Msh values. + References ---------- https://www.kennethmoreland.com/color-maps/ColorMapsExpanded.pdf @@ -571,6 +673,16 @@ class Colormap(mpl.colors.ListedColormap): """ Msh to CIE Lab. + Parameters + ---------- + msh : numpy.ndarray of shape (3) + Msh values. + + Returns + ------- + lab : numpy.ndarray of shape (3) + CIE lab values. + References ---------- https://www.kennethmoreland.com/color-maps/ColorMapsExpanded.pdf From 4d63da6aee57507fd9d099091b15a9597465a027 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Fri, 26 Nov 2021 11:34:43 -0500 Subject: [PATCH 5/6] get_file_handle suffix is optional --- python/damask/_colormap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 8f694ad45..51416f463 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -261,7 +261,7 @@ class Colormap(mpl.colors.ListedColormap): def _get_file_handle(self, fname: Union[TextIO, str, Path, None], - suffix: str) -> TextIO: + suffix: str = '') -> TextIO: """ Provide filehandle. @@ -270,7 +270,7 @@ class Colormap(mpl.colors.ListedColormap): fname : file, str, pathlib.Path, or None Filename or filehandle. If None, colormap name + suffix. - suffix: str + suffix: str, optional Extension to use for colormap filename. Returns From dc3db90ce0039d6a9dd95e062ceeb5c2f4d7f841 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 2 Dec 2021 18:59:31 -0500 Subject: [PATCH 6/6] fixed typo: colormodel --> color model --- python/damask/_colormap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/_colormap.py b/python/damask/_colormap.py index 51416f463..5c0a7abb7 100644 --- a/python/damask/_colormap.py +++ b/python/damask/_colormap.py @@ -95,7 +95,7 @@ class Colormap(mpl.colors.ListedColormap): N : int, optional Number of color quantization levels. Defaults to 256. model : {'rgb', 'hsv', 'hsl', 'xyz', 'lab', 'msh'} - Colormodel used for input color definitions. Defaults to `rgb`. + Color model used for input color definitions. Defaults to `rgb`. The available color models are: - 'rgb': Red Green Blue. - 'hsv': Hue Saturation Value.