Skip to content

Commit ba0c6a1

Browse files
committed
utils/types: fixed regexs
1 parent 2301514 commit ba0c6a1

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

src/pymcnp/inp/card_.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ def from_mcnp(cls, source: str):
3333
if not tokens:
3434
raise errors.InpError(errors.InpCode.SYNTAX_OPTION, source)
3535

36-
print(source)
37-
print(cls._REGEX.pattern)
38-
print(tokens.groups())
39-
4036
attrs = {}
4137
for i, (name, attr) in enumerate(cls._ATTRS.items()):
4238
if isinstance(attr, types.GenericAlias):

src/pymcnp/utils/types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ class Location(_object.McnpElement_):
14601460
z: Location z-coordinate.
14611461
"""
14621462

1463-
_REGEX = re.compile(r'( \S+)( \S+)( \S+)')
1463+
_REGEX = re.compile(r'(\S+) (\S+) (\S+)')
14641464

14651465
def __init__(self, x: Real, y: Real, z: Real):
14661466
"""
@@ -1505,7 +1505,7 @@ def from_mcnp(source: str):
15051505
"""
15061506

15071507
source, comments = _parser.preprocess_inp(source)
1508-
tokens = Location._REGEX.match(' ' + source)
1508+
tokens = Location._REGEX.match(source)
15091509

15101510
if not tokens:
15111511
raise errors.McnpError(errors.McnpCode.SYNTAX_TYPE, source)
@@ -2197,7 +2197,7 @@ class Index(_object.McnpElement_):
21972197
upper: Upper index.
21982198
"""
21992199

2200-
_REGEX = re.compile(r'( \S+):( \S+)')
2200+
_REGEX = re.compile(r'(\S+):(\S+)')
22012201

22022202
def __init__(self, lower: Integer, upper: Integer):
22032203
"""
File renamed without changes.

tests/data/inp/test0.i

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
MCNP Test Model for MOAA
2+
C cells
3+
c
4+
1 1 20
5+
-1000 $ dollar comment
6+
imp:n,p=1 trcl=5
7+
u=1
8+
2 2 8
9+
-1005
10+
imp:n=1
11+
imp:p=0.5
12+
lat 1
13+
fill= 0:1 0:1 0:0 1 0 1 5
14+
3 3 -1
15+
1000 1005 -1010
16+
imp:n,p=1
17+
99 0
18+
1010
19+
imp:n,p=0
20+
fill=1
21+
5 0
22+
#99
23+
imp:n,p=3
24+
c foo end comment
25+
26+
C surfaces
27+
1000 SO 1
28+
1005 RCC 0 1.5 -0.5 0 0 1 0.25
29+
1010 SO 3
30+
31+
C data
32+
C materials
33+
C UO2 5 atpt enriched
34+
m1 92235 5 &
35+
92238 95
36+
c testing comments
37+
sc1 This is a high quality source comment
38+
Fc5 Such a good tally comment.
39+
C Iron
40+
m2 26054 5.85
41+
26056 91.75
42+
26057 2.12
43+
26058 0.28
44+
C water
45+
m3 1001 2
46+
8016 1
47+
MT3 lwtr
48+
TR5 0.0 0.0 1.0 1 1 2 3 4 5 2 1 3 1
49+
C execution
50+
ksrc 0 0 0
51+
mode n p
52+
vol NO 2J 1 1.5 J
53+
E0 1 10 100

0 commit comments

Comments
 (0)