From a3a28d094ac821fd5df9927b194087e9b223f061 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 26 Aug 2022 16:22:08 +0100 Subject: [PATCH] changing RunTimeError to ValueError --- openmc/mesh.py | 6 +++--- tests/unit_tests/test_mesh_to_vtk.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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})