KeyError more sensible here

This commit is contained in:
Martin Diehl 2022-03-07 11:28:17 +01:00
parent bc020a9580
commit fe8e55e470
3 changed files with 3 additions and 3 deletions

View File

@ -498,7 +498,7 @@ class VTK:
# string array
return np.array([vtk_array.GetValue(i) for i in range(vtk_array.GetNumberOfValues())]).astype(str)
except UnboundLocalError:
raise ValueError(f'array "{label}" not found')
raise KeyError(f'array "{label}" not found')
def show(self,

View File

@ -61,7 +61,7 @@ class TestGrid:
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.save(tmp_path/'no_materialpoint.vti',parallel=False)
with pytest.raises(ValueError):
with pytest.raises(KeyError):
Grid.load(tmp_path/'no_materialpoint.vti')
def test_invalid_material_type(self):

View File

@ -141,7 +141,7 @@ class TestVTK:
def test_invalid_get(self,default):
with pytest.raises(ValueError):
with pytest.raises(KeyError):
default.get('does_not_exist')
def test_invalid_add_shape(self,default):