Skip to content

Commit 26cef14

Browse files
committed
utils/types: added horizontal entry support
1 parent 8eafcfa commit 26cef14

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

src/pymcnp/utils/types.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,9 +2731,9 @@ class IntegerOrJump(_object.McnpElement_):
27312731
value: Integer value or jump.
27322732
"""
27332733

2734-
_REGEX = re.compile(r'(?:[-+0-9.eE]+|\d*j|j)')
2734+
_REGEX = re.compile(r'(?:[-+0-9.eE]+|\d*j|\d*log|\d*ilog|\d*m|\d*i|\d*r)')
27352735

2736-
def __init__(self, value: int | Jump):
2736+
def __init__(self, value: int | Repeat | Insert | Multiply | Jump | Log):
27372737
"""
27382738
Initializes ``IntegerOrJump``.
27392739
@@ -2769,11 +2769,31 @@ def from_mcnp(source: str):
27692769

27702770
source, comments = _parser.preprocess_inp(source)
27712771

2772+
try:
2773+
return IntegerOrJump(Repeat.from_mcnp(source))
2774+
except errors.McnpError:
2775+
pass
2776+
2777+
try:
2778+
return IntegerOrJump(Insert.from_mcnp(source))
2779+
except errors.McnpError:
2780+
pass
2781+
2782+
try:
2783+
return IntegerOrJump(Multiply.from_mcnp(source))
2784+
except errors.McnpError:
2785+
pass
2786+
27722787
try:
27732788
return IntegerOrJump(Jump.from_mcnp(source))
27742789
except errors.McnpError:
27752790
pass
27762791

2792+
try:
2793+
return IntegerOrJump(Log.from_mcnp(source))
2794+
except errors.McnpError:
2795+
pass
2796+
27772797
try:
27782798
return IntegerOrJump(Integer.from_mcnp(source).value)
27792799
except errors.McnpError:
@@ -2798,9 +2818,9 @@ class RealOrJump(_object.McnpElement_):
27982818
value: Real value or jump.
27992819
"""
28002820

2801-
_REGEX = re.compile(r'(?:[-+0-9.eE]+|\d*j|j)')
2821+
_REGEX = re.compile(r'(?:[-+0-9.eE]+|\d*j|\d*log|\d*ilog|\d*m|\d*i|\d*r)')
28022822

2803-
def __init__(self, value: int | Jump):
2823+
def __init__(self, value: int | Repeat | Insert | Multiply | Jump | Log):
28042824
"""
28052825
Initializes ``RealOrJump``.
28062826
@@ -2836,11 +2856,31 @@ def from_mcnp(source: str):
28362856

28372857
source, comments = _parser.preprocess_inp(source)
28382858

2859+
try:
2860+
return RealOrJump(Repeat.from_mcnp(source))
2861+
except errors.McnpError:
2862+
pass
2863+
2864+
try:
2865+
return RealOrJump(Insert.from_mcnp(source))
2866+
except errors.McnpError:
2867+
pass
2868+
2869+
try:
2870+
return RealOrJump(Multiply.from_mcnp(source))
2871+
except errors.McnpError:
2872+
pass
2873+
28392874
try:
28402875
return RealOrJump(Jump.from_mcnp(source))
28412876
except errors.McnpError:
28422877
pass
28432878

2879+
try:
2880+
return RealOrJump(Log.from_mcnp(source))
2881+
except errors.McnpError:
2882+
pass
2883+
28442884
try:
28452885
return RealOrJump(Real.from_mcnp(source).value)
28462886
except errors.McnpError:

0 commit comments

Comments
 (0)