Skip to content

fix[next]: raise on disjoint inverse image#2616

Open
havogt wants to merge 1 commit into
GridTools:mainfrom
havogt:fix-hyperslice-disjoint
Open

fix[next]: raise on disjoint inverse image#2616
havogt wants to merge 1 commit into
GridTools:mainfrom
havogt:fix-hyperslice-disjoint

Conversation

@havogt
Copy link
Copy Markdown
Contributor

@havogt havogt commented May 29, 2026

small bug discovered by claude on the side

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the embedded NdArrayConnectivityField.inverse_image() path where a disjoint inverse image (no indices mapping into the requested image range) could previously crash inside _hyperslice(); it now cleanly triggers the existing ValueError for non-contiguous/invalid restrictions. A regression test is added to ensure this behavior is enforced.

Changes:

  • Make _hyperslice() return None when the selected mask is empty (disjoint inverse image), avoiding min/max on empty indices.
  • Add a unit test asserting premap() raises ValueError for a disjoint inverse image.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/gt4py/next/embedded/nd_array_field.py Prevents _hyperslice() from crashing on empty selections so disjoint inverse images raise the intended ValueError.
tests/next_tests/unit_tests/embedded_tests/test_nd_array_field.py Adds regression coverage for premap() when the connectivity’s inverse image is disjoint from the field domain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants