Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Error with tally specification #602

Open
MicahGale opened this issue Dec 3, 2024 · 0 comments
Open

Parsing Error with tally specification #602

MicahGale opened this issue Dec 3, 2024 · 0 comments
Labels
alpha testing Issues that came up during alpha testing bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". parsers are hard Examples of where MCNP syntax is complicated and should be simplified.

Comments

@MicahGale
Copy link
Collaborator

Describe the bug

When reading a tally with nested universes a parsing error occurs

To Reproduce

problem = montepy.read_input("foo.imcnp")

Error Message (if any)

If an error message was printed please include the entire stacktrace. If it includes any specific values please change or remove them. For example:

    @pytest.mark.parametrize("model", [p for p in Path("tests/models").glob("**/*.imcnp") if "success" not in str(p)])
    def test_read_model(model):
>       montepy.read_input(model)

tests/test_read.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../mambaforge/lib/python3.12/site-packages/montepy/input_parser/input_reader.py:31: in read_input
    problem.parse_input(replace=replace)
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_problem.py:382: in parse_input
    raise e
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_problem.py:367: in parse_input
    obj = obj_parser(input)
../../mambaforge/lib/python3.12/site-packages/montepy/data_inputs/data_parser.py:47: in parse_data
    return data_input.DataInput(input, prefix=prefix)
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:45: in wrapped
    add_line_number_to_exception(e, self)
../../mambaforge/lib/python3.12/site-packages/montepy/errors.py:232: in add_line_number_to_exception
    raise error
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:41: in wrapped
    return func(*args, **kwargs)
../../mambaforge/lib/python3.12/site-packages/montepy/data_inputs/data_input.py:343: in __init__
    super().__init__(input, fast_parse)
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:45: in wrapped
    add_line_number_to_exception(e, self)
../../mambaforge/lib/python3.12/site-packages/montepy/errors.py:232: in add_line_number_to_exception
    raise error
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:41: in wrapped
    return func(*args, **kwargs)
../../mambaforge/lib/python3.12/site-packages/montepy/data_inputs/data_input.py:58: in __init__
    super().__init__(input, self._parser)
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:45: in wrapped
    add_line_number_to_exception(e, self)
../../mambaforge/lib/python3.12/site-packages/montepy/errors.py:256: in add_line_number_to_exception
    raise error.with_traceback(trace)
../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:41: in wrapped
    return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[TypeError("    tests/models/irphep/KRITZ-LWR-RESR-002_Kritz2-1_highT.imcnp, line 355\n\n       356| f4:n  (5 < u=1 < u=2)\n'NoneType' object is not subscriptable") raised in repr()] DataInput object at 0x7f1aa50ebaa0>
input = INPUT: BlockType.DATA: ['f4:n  (5 < u=1 < u=2)'], parser = <montepy.input_parser.tally_parser.TallyParser object at 0x7f1aa4fb63c0>

    def __init__(self, input, parser):
        self._problem_ref = None
        self._parameters = ParametersNode()
        self._input = None
        if input:
            if not isinstance(input, montepy.input_parser.mcnp_input.Input):
                raise TypeError("input must be an Input")
            try:
                try:
                    parser.restart()
                # raised if restarted without ever parsing
                except AttributeError as e:
                    pass
                self._tree = parser.parse(input.tokenize(), input)
                self._input = input
            except ValueError as e:
                raise MalformedInputError(
                    input, f"Error parsing object of type: {type(self)}: {e.args[0]}"
                )
            if self._tree is None:
>               raise ParsingError(
                    input,
                    "",
                    parser.log.clear_queue(),
                )
E               montepy.errors.ParsingError:     tests/models/irphep/KRITZ-LWR-RESR-002_Kritz2-1_highT.imcnp, line 355
E
E                      356| f4:n  (5 < u=1 < u=2)
E                   tests/models/irphep/KRITZ-LWR-RESR-002_Kritz2-1_highT.imcnp, line 356
E
E                   >  356| f4:n  (5 < u=1 < u=2)
E                         |          ^ not expected here.
E               There was an error parsing "<".
E               sly: Syntax error at line 1, token=PARTICLE_SPECIAL

../../mambaforge/lib/python3.12/site-packages/montepy/mcnp_object.py:119: ParsingError

MCNP input file snippet

The culprit is:

f4:n (5< u=1 < u=2)

Version

  • Version 1.0.0a1dev306

Additional context

Add any other context about the problem here.

@MicahGale MicahGale added alpha testing Issues that came up during alpha testing bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". parsers are hard Examples of where MCNP syntax is complicated and should be simplified. labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha testing Issues that came up during alpha testing bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". parsers are hard Examples of where MCNP syntax is complicated and should be simplified.
Projects
None yet
Development

No branches or pull requests

1 participant