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

Implemented contains for BoundingBox containing other BoundingBox #2906

Merged
merged 8 commits into from
Mar 21, 2024

Conversation

MicahGale
Copy link
Contributor

@MicahGale MicahGale commented Mar 11, 2024

Description

This is a quality of life feature request that tests if things are inside of a BoundingBox. Originally the goal was to have if point in box and if other_box in box. Turns out since #2759, if point in box has been implemented.

This PR does the following:

  • Implement checking if a bounding box is inside of another: if other_box in box
  • Implements length enforcement for points so: [1]*100 in box gives a helpful error.
  • Implements type checking so if "foo" in box gives a helpful error.
  • Adds two unit tests to test the __contains__ function for BoundingBox to test it's accuracy, and the other tests it's error handling.

It is unclear if this should be explicitly documented for users or not.

Fixes #2896

Checklist

  • I have performed a self-review of my own code
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@MicahGale
Copy link
Contributor Author

@shimwell, do you want to look at this since it seems like you did the initial implementation for this.

openmc/bounding_box.py Outdated Show resolved Hide resolved
openmc/bounding_box.py Outdated Show resolved Hide resolved
@shimwell
Copy link
Member

This looks like a useful feature to me. I've made a few comments for consideration but nothing major

I would recommend one more test that checks a bounding box is in another bounding box when the first bounding box is only partly within. This would return false.

@MicahGale
Copy link
Contributor Author

Ok that test was added. I also added one for one of the vertices being coincident because the objects were right there.

@MicahGale MicahGale requested a review from shimwell March 13, 2024 21:04
Copy link
Member

@shimwell shimwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice PR that improves on the existing contains method to supports bounding boxes, includes tests, doc strings updates, pep8 formatting. All looks good to me and I'm happy to merge this one in. Many thanks for this improved method

Will merge Tuesday afternoon (UK time) if there are no objections.

@shimwell shimwell added the Merging Soon PR will be merged in < 24 hrs if no further comments are made. label Mar 17, 2024
@MicahGale
Copy link
Contributor Author

Thanks @shimwell.

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to take a look at this before we merge. Sorry to delay! Will get a review in asap

@shimwell shimwell removed the Merging Soon PR will be merged in < 24 hrs if no further comments are made. label Mar 20, 2024
@paulromano paulromano merged commit 23f19a0 into openmc-dev:develop Mar 21, 2024
18 checks passed
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement contains for BoundingBox
4 participants