Skip to content

Conversation

@MicahGale
Copy link
Collaborator

@MicahGale MicahGale commented Jan 18, 2026

Pull Request Checklist for MontePy

Description

This fixes a bug with how __iand__ and __ior__ operate in HalfSpace. This bug is only apparent when intersections and unions are combined in a single expression. Quite frankly I don't understand the previous logic, and it was rather elaborate to handle the operations incorrectly. The notes in 4107b14 have better details:

  • I honestly don't know what I was thinking previously this was so
    complicated and just wrong.
  • The principle I used was that &= ands the new thing against
    everything.
    • i.e., (old) & new
  • For example:
  • If you have: existing geometry: +1:+2
    &= -3 should yield: (+1:+2)&-3
  • For a binary tree this means:

           &
         /  \
        |    -3
       / \
      +1 +2

For testing the structure of mixed intersection and union definitions is actually tested. The string representation is also tested more, in part to make the test more readable. Finally, the export is tested with Cell.mcnp_str

Fixes #879


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 25.
  • I have added tests that prove my fix is effective or that my feature works (if applicable).

LLM Disclosure

Were any large language models (LLM or "AI") used in to generate any of this code?

  • Yes
    • Model(s) used:
  • No

Documentation Checklist

  • I have documented all added classes and methods.
  • For infrastructure updates, I have updated the developer's guide.
  • 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--882.org.readthedocs.build/en/882/

* I honestly don't know what I was thinking previously this was so
  complicated and just wrong.
* The principle I used was that &= ands the new thing against
  everything.
	* i.e., (old) & new
* For example:
* If you have: existing geometry: +1:+2
	&= -3 should yield: (+1:+2)&-3
* For a binary tree this means:

            &
          /  \
         |    -3
        / \
       +1 +2
@MicahGale MicahGale linked an issue Jan 18, 2026 that may be closed by this pull request
@MicahGale MicahGale self-assigned this Jan 18, 2026
@MicahGale MicahGale added the bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". label Jan 18, 2026
@MicahGale MicahGale requested a review from tjlaboss January 18, 2026 01:54
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".

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider implicit parentheses operating on existing regions

2 participants