Skip to content

Commit 8d179e2

Browse files
committed
types: added macrobody facets
1 parent 6ae61c4 commit 8d179e2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/pymcnp/utils/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ class Geometry(_object.McnpNonterminal):
983983
infix: Geometry infix formula.
984984
"""
985985

986-
_REGEX = re.compile(r'\A((?:).+)\Z')
986+
_REGEX = re.compile(r'\A(.+)\Z')
987987

988988
def __init__(self, infix: String):
989989
"""
@@ -1008,6 +1008,10 @@ def __init__(self, infix: String):
10081008
temp = re.sub(r'\+-', '-', temp)
10091009
temp = re.sub(r'(\d)\(', r'\1*(', temp)
10101010

1011+
for number in re.split(r'[*#:+ ()-]+', temp):
1012+
if number and not re.match(r'\d+(?:[.][1-8])?', number):
1013+
raise errors.McnpError(errors.McnpCode.SEMANTICS_TYPE, infix)
1014+
10111015
try:
10121016
eval(temp)
10131017
except SyntaxError:

tests/inp/test_card.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ class Test_FromMcnp(_utils._Test_FromMcnp):
2525
'2 3 -3.7 -1 IMP:N=2 IMP:P=4',
2626
#'3 LIKE 2 BUT IMP:N=10 TRCL=1',
2727
'10 16 -4.2 1 -2 3 IMP:N=4 IMP:P=8 EXT:N=-0.4',
28-
#'3 0 -1.2 -1.1 1.4 -1.5 -1.6 99',
29-
#'4 0 1.1 -2001.1 -5.3 -5.5 -5.6 -5.4',
28+
'3 0 -1.2 -1.1 1.4 -1.5 -1.6 99',
29+
'4 0 1.1 -2001.1 -5.3 -5.5 -5.6 -5.4',
3030
'5 0 -5',
3131
'1 0 -1',
3232
#'2 like 1 but trcl = (2 0 0)',
33-
#'9 0 (-5.1:1.3:2001.1:-99:5.5:5.6) #5',
34-
#'3 0 5.1 -1.1 -5.3 -5.5 -5.6 99',
35-
#'3 0 5.1 -1.1 1.4 -5.5 -5.6 -5.4',
36-
#'3 0 -1.2 -1.1 -5.3 -5.5 -5.6 -5.4',
33+
'9 0 (-5.1:1.3:2001.1:-99:5.5:5.6) #5',
34+
'3 0 5.1 -1.1 -5.3 -5.5 -5.6 99',
35+
'3 0 5.1 -1.1 1.4 -5.5 -5.6 -5.4',
36+
'3 0 -1.2 -1.1 -5.3 -5.5 -5.6 -5.4',
3737
'1 0 1 -2 3 $ cell 1',
3838
# 3.3
3939
'1 0 -17 $ rcc can',

0 commit comments

Comments
 (0)