changing RunTimeError to ValueError

This commit is contained in:
Jonathan Shimwell 2022-08-26 16:22:08 +01:00
parent 922a5fcf5a
commit a3a28d094a
2 changed files with 4 additions and 4 deletions

View file

@ -216,7 +216,7 @@ class StructuredMesh(MeshBase):
Raises
------
RuntimeError
ValueError
When the size of a dataset doesn't match the number of mesh cells
Returns
@ -236,10 +236,10 @@ class StructuredMesh(MeshBase):
)
if isinstance(dataset, np.ndarray):
if not dataset.size == self.num_mesh_cells:
raise RuntimeError(errmsg)
raise ValueError(errmsg)
else:
if len(dataset) == self.num_mesh_cells:
raise RuntimeError(errmsg)
raise ValueError(errmsg)
cv.check_type('label', label, str)
vtk_grid = vtk.vtkStructuredGrid()

View file

@ -80,5 +80,5 @@ def test_write_data_to_vtk_size_mismatch(mesh):
f"The size of the dataset 'label' \({len(data)}\) should be equal to "
f"the number of mesh cells \({mesh.num_mesh_cells}\)"
)
with pytest.raises(RuntimeError, match=expected_error_msg):
with pytest.raises(ValueError, match=expected_error_msg):
mesh.write_data_to_vtk(filename="out.vtk", datasets={"label": data})