Skip to content

Add covers method and make contains boundary semantics consistent - #680

Merged
larrybradley merged 10 commits into
astropy:mainfrom
larrybradley:fix-poly-contains
Jun 10, 2026
Merged

Add covers method and make contains boundary semantics consistent#680
larrybradley merged 10 commits into
astropy:mainfrom
larrybradley:fix-poly-contains

Conversation

@larrybradley

Copy link
Copy Markdown
Member

Region contains methods were inconsistent at the boundary: EllipsePixelRegion.contains included it, Circle/Rectangle excluded it, and PolygonPixelRegion.contains was ambiguous on edges/vertices.

This PR makes contains strictly exclude the boundary for all pixel regions (matching Shapely's contains and DE-9IM) and adds a new covers method that includes the boundary (matching Shapely's covers). The polygon implementation gains an explicit point-on-segment test, and the subpixel mask sampler uses the boundary-inclusive variant.

The contains methods of all regions now also ignore the 'include' metadata attribute (which was previously used to invert evaluation results), making containment and covering behavior depend solely on the geometric shape of the region.

@larrybradley larrybradley added this to the 0.12 milestone Jun 10, 2026
@larrybradley
larrybradley merged commit 7cb98f1 into astropy:main Jun 10, 2026
30 of 31 checks passed
@larrybradley
larrybradley deleted the fix-poly-contains branch June 10, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant