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

add point_is_inside to BaseRegionOfInterest #413

Merged
merged 6 commits into from
Feb 13, 2025
Merged

Conversation

stellaprins
Copy link
Contributor

@stellaprins stellaprins commented Feb 12, 2025

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
To enable implementation of event arrays.
What does this PR do?
Enables to determine if a position (a Shapely 2D or 3D point) is inside the region of interest (by default including the boundary of the region).

References

#408

How has this PR been tested?

Tests added for a polygon with a hole and a line (with and without boundaries)

Is this a breaking change?

No.

Does this PR require an update to the documentation?

No, not necessarily. But down the line the functionality could be used in an example. See #415.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@stellaprins stellaprins self-assigned this Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.83%. Comparing base (0e1951d) to head (e7c8a52).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #413   +/-   ##
=======================================
  Coverage   99.83%   99.83%           
=======================================
  Files          22       22           
  Lines        1207     1219   +12     
=======================================
+ Hits         1205     1217   +12     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@niksirbi niksirbi marked this pull request as ready for review February 13, 2025 11:32
@niksirbi niksirbi self-requested a review February 13, 2025 11:32
Copy link
Member

@niksirbi niksirbi left a comment

Choose a reason for hiding this comment

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

Looks good to go @stellaprins (apart from a few pedantic suggestions).

I would also like to put forward a suggesiton for naming the method as contains_point instead of point_is_inside.

My reasoning is explained in the following mock code snippet:

poly = PolygonOfInterest(exterior_boundary)
poly.contains_point(data_array)   # this reads more natural to me
poly.point_is_inside(data_array)  # understandable, but doesn't flow as nicely

Opinions on this @stellaprins, @willGraham01?

tests/test_unit/test_roi/test_points_within_roi.py Outdated Show resolved Hide resolved
tests/test_unit/test_roi/test_points_within_roi.py Outdated Show resolved Hide resolved
tests/test_unit/test_roi/test_points_within_roi.py Outdated Show resolved Hide resolved
@niksirbi
Copy link
Member

I also opened a new issue #415 to showcase this feature in an example (assigned to myself).

@willGraham01
Copy link
Contributor

I would also like to put forward a suggesiton for naming the method as contains_point instead of point_is_inside.

No strong opinions, happy to go with this - you are right that "polygon contains point" reads better than "polygon point is inside"

@stellaprins
Copy link
Contributor Author

Thanks for the suggestions @niksirbi

I would also like to put forward a suggesiton for naming the method as contains_point instead of point_is_inside.
Sounds good!

All done.

@stellaprins stellaprins added this pull request to the merge queue Feb 13, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2025
* add point_is_inside to BaseRegionOfInterest

* match length underlining docstring to title

* add point within LoI tests and test excluded boundaries

* reformat test names and docstrings

* change point_is_inside to contains_point
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2025
@niksirbi niksirbi added this pull request to the merge queue Feb 13, 2025
Merged via the queue into main with commit 4269319 Feb 13, 2025
18 checks passed
@willGraham01 willGraham01 deleted the sp/408-points-within-roi branch February 14, 2025 08:59
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.

3 participants