diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 0fd14dbf5..0077a0309 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -688,14 +688,14 @@ class Grid: def show(self, - colormap: Colormap = None) -> None: + colormap: Union[Colormap, str] = None) -> None: """ Show on screen. Parameters ---------- - colormap : damask.Colormap, optional - Colors used to map material IDs. Defaults to 'cividis'. + colormap : damask.Colormap or str, optional + Colormap for visualization of material IDs. Defaults to 'cividis'. """ VTK.from_image_data(self.cells,self.size,self.origin) \ diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 90f5e2a1c..13b345091 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -503,7 +503,7 @@ class VTK: def show(self, label: str = None, - colormap: Colormap = None): + colormap: Union[Colormap, str] = None): """ Render. @@ -511,8 +511,8 @@ class VTK: ---------- label : str, optional Label of the dataset to show. - colormap : damask.Colormap, optional - Colormap for visualization of dataset. + colormap : damask.Colormap or str, optional + Colormap for visualization of dataset. Defaults to 'cividis'. Notes ----- @@ -535,7 +535,9 @@ class VTK: height = 768 lut = vtk.vtkLookupTable() - colormap_ = Colormap.from_predefined('cividis') if colormap is None else colormap + colormap_ = Colormap.from_predefined('cividis') if colormap is None \ + else Colormap.from_predefined(colormap) if isinstance(colormap,str) \ + else colormap lut.SetNumberOfTableValues(len(colormap_.colors)) for i,c in enumerate(colormap_.colors): lut.SetTableValue(i,c if len(c)==4 else np.append(c,1.0)) diff --git a/python/tests/test_Grid.py b/python/tests/test_Grid.py index 4ef62ff93..417d92507 100644 --- a/python/tests/test_Grid.py +++ b/python/tests/test_Grid.py @@ -6,6 +6,7 @@ from damask import VTK from damask import Grid from damask import Table from damask import Rotation +from damask import Colormap from damask import util from damask import seeds from damask import grid_filters @@ -42,9 +43,10 @@ class TestGrid: print('patched datetime.datetime.now') - def test_show(sef,default,monkeypatch): + @pytest.mark.parametrize('cmap',[Colormap.from_predefined('cividis'),'cividis',None]) + def test_show(sef,default,cmap,monkeypatch): monkeypatch.delenv('DISPLAY',raising=False) - default.show() + default.show(cmap) def test_equal(self,default): assert default == default diff --git a/python/tests/test_VTK.py b/python/tests/test_VTK.py index 684a05678..2cf7e411f 100644 --- a/python/tests/test_VTK.py +++ b/python/tests/test_VTK.py @@ -10,6 +10,7 @@ import vtk from damask import VTK from damask import Table +from damask import Colormap @pytest.fixture def ref_path(ref_path_base): @@ -29,10 +30,10 @@ class TestVTK: def _patch_execution_stamp(self, patch_execution_stamp): print('patched damask.util.execution_stamp') - def test_show(sef,default,monkeypatch): + @pytest.mark.parametrize('cmap',[Colormap.from_predefined('cividis'),'cividis',None]) + def test_show(sef,default,cmap,monkeypatch): monkeypatch.delenv('DISPLAY',raising=False) - default.show() - + default.show(colormap=cmap) def test_imageData(self,tmp_path): cells = np.random.randint(5,10,3) diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index 691578fd0..399bb180a 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -81,7 +81,7 @@ subroutine discretization_grid_init(restart) if (any(materialAt_global < 1)) & call IO_error(180,ext_msg='material ID < 1') if (size(materialAt_global) /= product(cells)) & - call IO_error(180,ext_msg='mismatch of material IDs and # cells') + call IO_error(180,ext_msg='mismatch in # of material IDs and cells') fname = interface_geomFile if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:) call results_openJobFile(parallel=.false.)