KeyError more sensible here
This commit is contained in:
parent
bc020a9580
commit
fe8e55e470
|
@ -498,7 +498,7 @@ class VTK:
|
||||||
# string array
|
# string array
|
||||||
return np.array([vtk_array.GetValue(i) for i in range(vtk_array.GetNumberOfValues())]).astype(str)
|
return np.array([vtk_array.GetValue(i) for i in range(vtk_array.GetNumberOfValues())]).astype(str)
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
raise ValueError(f'array "{label}" not found')
|
raise KeyError(f'array "{label}" not found')
|
||||||
|
|
||||||
|
|
||||||
def show(self,
|
def show(self,
|
||||||
|
|
|
@ -61,7 +61,7 @@ class TestGrid:
|
||||||
def test_invalid_no_material(self,tmp_path):
|
def test_invalid_no_material(self,tmp_path):
|
||||||
v = VTK.from_image_data(np.random.randint(5,10,3)*2,np.random.random(3) + 1.0)
|
v = VTK.from_image_data(np.random.randint(5,10,3)*2,np.random.random(3) + 1.0)
|
||||||
v.save(tmp_path/'no_materialpoint.vti',parallel=False)
|
v.save(tmp_path/'no_materialpoint.vti',parallel=False)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(KeyError):
|
||||||
Grid.load(tmp_path/'no_materialpoint.vti')
|
Grid.load(tmp_path/'no_materialpoint.vti')
|
||||||
|
|
||||||
def test_invalid_material_type(self):
|
def test_invalid_material_type(self):
|
||||||
|
|
|
@ -141,7 +141,7 @@ class TestVTK:
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_get(self,default):
|
def test_invalid_get(self,default):
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(KeyError):
|
||||||
default.get('does_not_exist')
|
default.get('does_not_exist')
|
||||||
|
|
||||||
def test_invalid_add_shape(self,default):
|
def test_invalid_add_shape(self,default):
|
||||||
|
|
Loading…
Reference in New Issue