give default directly

only Colormap object caused problem (tab completion triggered '__repr__'
which means showing colormap in maplotlib window
This commit is contained in:
Martin Diehl 2022-03-08 22:43:54 +01:00
parent 73f01c07d0
commit c4a7c0096a
4 changed files with 7 additions and 8 deletions

View File

@ -688,7 +688,7 @@ class Grid:
def show(self,
colormap: Union[Colormap, str] = None) -> None:
colormap: Union[Colormap, str] = 'cividis') -> None:
"""
Show on screen.

View File

@ -503,7 +503,7 @@ class VTK:
def show(self,
label: str = None,
colormap: Union[Colormap, str] = None):
colormap: Union[Colormap, str] = 'cividis'):
"""
Render.
@ -516,7 +516,7 @@ class VTK:
Notes
-----
See http://compilatrix.com/article/vtk-1 for further ideas.
See http://compilatrix.com/article/vtk-1 for further ideas.
"""
try:
@ -535,9 +535,8 @@ class VTK:
height = 768
lut = vtk.vtkLookupTable()
colormap_ = Colormap.from_predefined('cividis') if colormap is None \
else Colormap.from_predefined(colormap) if isinstance(colormap,str) \
else colormap
colormap_ = 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))

View File

@ -43,7 +43,7 @@ class TestGrid:
print('patched datetime.datetime.now')
@pytest.mark.parametrize('cmap',[Colormap.from_predefined('cividis'),'cividis',None])
@pytest.mark.parametrize('cmap',[Colormap.from_predefined('stress'),'viridis'])
def test_show(sef,default,cmap,monkeypatch):
monkeypatch.delenv('DISPLAY',raising=False)
default.show(cmap)

View File

@ -30,7 +30,7 @@ class TestVTK:
def _patch_execution_stamp(self, patch_execution_stamp):
print('patched damask.util.execution_stamp')
@pytest.mark.parametrize('cmap',[Colormap.from_predefined('cividis'),'cividis',None])
@pytest.mark.parametrize('cmap',[Colormap.from_predefined('cividis'),'strain'])
def test_show(sef,default,cmap,monkeypatch):
monkeypatch.delenv('DISPLAY',raising=False)
default.show(colormap=cmap)