diff --git a/openmc/mesh.py b/openmc/mesh.py index 1b37a42728..8ac4b15946 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -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() diff --git a/tests/unit_tests/test_mesh_to_vtk.py b/tests/unit_tests/test_mesh_to_vtk.py index 2c23a52985..d7d5907a22 100644 --- a/tests/unit_tests/test_mesh_to_vtk.py +++ b/tests/unit_tests/test_mesh_to_vtk.py @@ -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})