mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Bug fix in Region.from_expression during tokenization (#2733)
This commit is contained in:
parent
55a682d44d
commit
f82bdaa718
2 changed files with 7 additions and 6 deletions
|
|
@ -105,17 +105,17 @@ class Region(ABC):
|
|||
# If special character appears immediately after a non-operator,
|
||||
# create a token with the appropriate half-space
|
||||
if i_start >= 0:
|
||||
# When an opening parenthesis appears after a non-operator,
|
||||
# there's an implicit intersection operator between them
|
||||
if expression[i] == '(':
|
||||
tokens.append(' ')
|
||||
|
||||
j = int(expression[i_start:i])
|
||||
if j < 0:
|
||||
tokens.append(-surfaces[abs(j)])
|
||||
else:
|
||||
tokens.append(+surfaces[abs(j)])
|
||||
|
||||
# When an opening parenthesis appears after a non-operator,
|
||||
# there's an implicit intersection operator between them
|
||||
if expression[i] == '(':
|
||||
tokens.append(' ')
|
||||
|
||||
if expression[i] in '()|~':
|
||||
# For everything other than intersection, add the operator
|
||||
# to the list of tokens
|
||||
|
|
|
|||
|
|
@ -208,7 +208,8 @@ def test_from_expression(reset):
|
|||
# Opening parenthesis immediately after halfspace
|
||||
r = openmc.Region.from_expression('1(2|-3)', surfs)
|
||||
assert str(r) == '(1 (2 | -3))'
|
||||
|
||||
r = openmc.Region.from_expression('-1|(1 2(-3))', surfs)
|
||||
assert str(r) == '(-1 | (1 2 -3))'
|
||||
|
||||
def test_translate_inplace():
|
||||
sph = openmc.Sphere()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue