mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
replace is_flat by a one-line check
This commit is contained in:
parent
ba1cd67d52
commit
c84336878b
2 changed files with 4 additions and 36 deletions
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue