Skip to content

Fix bugs with how 0s are handled by Universe Inputs - #1052

Open
MicahGale wants to merge 7 commits into
patch_devfrom
1051-universe-0-in-a-u-data-input-a-repeated-0-crashes-the-write-and-trailing-zeros-are-dropped
Open

MicahGale wants to merge 7 commits into
patch_devfrom
1051-universe-0-in-a-u-data-input-a-repeated-0-crashes-the-write-and-trailing-zeros-are-dropped

Conversation

@MicahGale

@MicahGale MicahGale commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request Checklist for MontePy

Description

This fixes a few bugs with how UniverseInput handles zeros as brought up in #1051.

Bug in how 0 are transformed back to Jump.

In MCNP 0 and J are interchangeable for Universes. When an explicit 0 was created by 0 2R MontePy tried to coerce it back to a Jump, but not fully. This lead to internal errors with trying to combine it with the repeat shortcut.

This was solved by not coercing these explicit 0s back to Jump.

Dropping trailing Jumps from input.

Usually MCNP lets you drop extra final jumps and implicitly fills out the array. Though as pointed out in #1051 the manual states this is not allowed for a UniverseInput in the data block. These ones must always be explicitly set for every cell, even if just to Jump. To solve this one I just made a mechanism for not allowing the final jump to be dropped by default. This only really shows up with Universes are moved from the cell block where implicit universes are allowed, to the data block, where they are not allowed.

Fixes #1051


General Checklist

  • I have performed a self-review of my own code.
  • The code follows the standards outlined in the development documentation.
  • I have formatted my code with black version 26.
  • I have added tests that prove my fix is effective or that my feature works (if applicable).

LLM Disclosure

  1. Are you?

    • A human user
    • A large language model (LLM), including ones acting on behalf of a human
  2. Were any large language models (LLM or "AI") used in to generate any of this code?

  • Yes
    • Model(s) used:
    • Harness used:
    • Reasoning effort:
  • No

Documentation Checklist

  • I have documented all added classes and methods.
  • I have added type hints to all functions as needed.
  • I have marked all changes with the .. versionchanged:: or .. versionadded:: directives.

Infrastructure Changes

  • For infrastructure updates, I have updated the developer's guide.

Significant features or Behavior changes

  • For significant new features, I have added a section to the getting started guide.

First-Time Contributor Checklist

  • If this is your first contribution, add yourself to pyproject.toml if you wish to do so.

Additional Notes for Reviewers

Ensure that:

  • This PR fully addresses and resolves the referenced issue(s).
  • The submitted code is consistent with the merge checklist outlined here.
  • The PR covers all relevant aspects according to the development guidelines.
  • 100% coverage of the patch is achieved, or justification for a variance is given.

📚 Documentation preview 📚: https://montepy--1052.org.readthedocs.build/en/1052/

@MicahGale MicahGale self-assigned this Nov 5, 2026
@MicahGale MicahGale added 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 Nov 5, 2026
MicahGale and others added 3 commits November 5, 2026 13:22
A trailing jump kept by explicit_jumps has no end padding, so a value
appended after it was written as J350. ListNode.format now adds a space
after a shortcut when its output is not already whitespace-terminated.
Updated the universe data test input and assertions to cover this.

Co-Authored-By: Claude <noreply@anthropic.com>
…eated-0-crashes-the-write-and-trailing-zeros-are-dropped
@MicahGale
MicahGale marked this pull request as ready for review November 5, 2026 20:40
@MicahGale
MicahGale requested a review from tjlaboss November 5, 2026 20:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Successfully merging this pull request may close these issues.

1 participant