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

Uncaught iterator error in Fill #601

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

Uncaught iterator error in Fill #601

MicahGale opened this issue Dec 3, 2024 · 0 comments
Assignees
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". question Further information is requested

Comments

@MicahGale
Copy link
Collaborator

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

A short code snippet of what you have ran. Please change or remove any specific values or anything that can't be public. For example:

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:

../../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:367: in parse_input
    obj = obj_parser(input)
../../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/cell.py:95: in __init__
    self._parse_keyword_modifiers()
../../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/cell.py:119: in _parse_keyword_modifiers
    input = input_class(in_cell_block=True, key=key, value=value)
../../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/fill.py:46: in __init__
    self._parse_cell_input(key, value)
../../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/fill.py:144: in _parse_cell_input
    get_universe(value)
../../mambaforge/lib/python3.12/site-packages/montepy/data_inputs/fill.py:92: in get_universe
    self._parse_matrix(value)
../../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 = Fill: set_in_cell: True, in_cell: True old_number: None, old_transform: None old_numbers: [[[23 23 23 ... 23 23 23]
  ...e: None, universes: None, transform: None Multi_universe: True hidden_transform: None Min/Max: [-14 -14 -14] [14 14 14]
value = (Node: fill: {'classifier': (Classifier: mod: None, prefix: (Value, fill, padding: None), number: None, particles: Non..., padding: (Padding, [' '])), (Value, 23.0, padding: (Padding, [' '])), (Value, 23.0, padding: (Padding, [' ']))]))])})

    def _parse_matrix(self, value):
        """
        Parses a matrix fill of universes.

        :param value: the value in the cell
        :type value: str
        """
        self._multi_universe = True
        words = value["data"]
        self._min_index = np.zeros((3,), dtype=np.dtype(int))
        self._max_index = np.zeros((3,), dtype=np.dtype(int))
        limits_iter = (
            it.islice(words, 0, None, 3),
            it.islice(words, 1, None, 3),
            it.islice(words, 2, None, 3),
        )
        for axis, min_val, seperator, max_val in zip(
            Fill.DIMENSIONS.values(), *limits_iter
        ):
            for val, limit_holder in zip(
                (min_val, max_val), (self._min_index, self._max_index)
            ):
                try:
                    val._convert_to_int()
                    limit_holder[axis] = val.value
                except ValueError as e:
                    raise ValueError(
                        f"The lattice limits must be an integer. {val.value} was given"
                    )
        for min_val, max_val in zip(self.min_index, self.max_index):
            if min_val > max_val:
                raise ValueError(
                    "The minimum value must be smaller than the max value."
                    f"Min: {min_val}, Max: {max_val}, Input: {value.format()}"
                )
        self._old_numbers = np.zeros(self._sizes, dtype=np.dtype(int))
        words = iter(words[9:])
        for i in self._axis_range(0):
            for j in self._axis_range(1):
                for k in self._axis_range(2):
>                   val = next(words)
E                   StopIteration:
E
E                   Error came from Fill: Universe: None, transform: None from an unknown file.

MCNP input file snippet

MWE in progress

Version

  • Version 1.0.0a1dev306

Additional context

Add any other context about the problem here.

@MicahGale MicahGale added question Further information is requested 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". labels Dec 3, 2024
@MicahGale MicahGale self-assigned this 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". question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant