replace is_flat by a one-line check

This commit is contained in:
RemDelaporteMathurin 2023-01-27 08:58:10 -05:00
parent ba1cd67d52
commit c84336878b
2 changed files with 4 additions and 36 deletions

View file

@ -433,8 +433,8 @@ class RegularMesh(StructuredMesh):
cv.check_length('mesh lower_left', lower_left, 1, 3)
self._lower_left = lower_left
if self.is_flat():
raise ValueError("mesh cannot be flat")
if self.upper_right is not None and any(np.isclose(self.upper_right, lower_left)):
raise ValueError("mesh cannot have zero thickness is any dimension")
@upper_right.setter
def upper_right(self, upper_right):
@ -446,8 +446,8 @@ class RegularMesh(StructuredMesh):
self._width = None
warnings.warn("Unsetting width attribute.")
if self.is_flat():
raise ValueError("mesh cannot be flat")
if self.lower_left is not None and any(np.isclose(self.lower_left, upper_right)):
raise ValueError("mesh cannot have zero thickness is any dimension")
@width.setter
def width(self, width):
@ -792,16 +792,6 @@ class RegularMesh(StructuredMesh):
volume_normalization=volume_normalization
)
def is_flat(self):
"""Returns True if the mesh is flat
"""
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):
if val1 == val2:
return True
def Mesh(*args, **kwargs):
warnings.warn("Mesh has been renamed RegularMesh. Future versions of "
"OpenMC will not accept the name Mesh.")

View file

@ -33,25 +33,3 @@ 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()