diff --git a/openmc/mesh.py b/openmc/mesh.py index 962751f9b3..3cdfc87f3b 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -795,7 +795,7 @@ class RegularMesh(StructuredMesh): def is_flat(self): """Returns True if the mesh is flat """ - if None in [self.lower_left, self.upper_right]: + if self.lower_left is None or self.upper_right is None: return False for val1, val2 in zip(self.lower_left, self.upper_right): diff --git a/tests/unit_tests/test_mesh.py b/tests/unit_tests/test_mesh.py index 129e8e21b5..8bc00a2768 100644 --- a/tests/unit_tests/test_mesh.py +++ b/tests/unit_tests/test_mesh.py @@ -1,5 +1,6 @@ import openmc import pytest +import numpy as np @pytest.mark.parametrize("val_left,val_right", [(0, 0), (-1., -1.), (2.0, 2)]) def test_raises_error_when_flat(val_left, val_right): @@ -32,3 +33,25 @@ def test_raises_error_when_flat(val_left, val_right): with pytest.raises(ValueError): mesh.upper_right = [25, 25, val_right] mesh.lower_left = [-25, -25, val_left] + + +def test_corner_none_returns_false(): + """Checks mesh is not considered flat when one + corner is None + """ + mesh = openmc.RegularMesh() + mesh.lower_left = [-25, -25, -25] + assert not mesh.is_flat() + + mesh = openmc.RegularMesh() + mesh.upper_right = [-25, -25, -25] + assert not mesh.is_flat() + + # test with np array + mesh = openmc.RegularMesh() + mesh.lower_left = np.array([-25, -25, -25]) + assert not mesh.is_flat() + + mesh = openmc.RegularMesh() + mesh.upper_right = np.array([-25, -25, -25]) + assert not mesh.is_flat() \ No newline at end of file