mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
added test to catch bug + fix
This commit is contained in:
parent
a976703556
commit
ba1cd67d52
2 changed files with 24 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue