Skip to content

Exclude bounds coordinates from keyword indexers - #700

Open
FranklinNexus wants to merge 1 commit into
xarray-contrib:mainfrom
FranklinNexus:fix/keyword-indexers-with-bounds
Open

FranklinNexus wants to merge 1 commit into
xarray-contrib:mainfrom
FranklinNexus:fix/keyword-indexers-with-bounds

Conversation

@FranklinNexus

Copy link
Copy Markdown

Closes #245.

When a longitude coordinate and its bounds both have units="degrees_east", ds.cf.isel(longitude=1) forwards the indexer to both lon and lon_bnds. Xarray then raises ValueError because lon_bnds is not a dimension. Keyword indexers now match only dimensions or indexed coordinates. This also keeps sel working when its index coordinate has a different name from the dimension.

The regression test compares the results with native xarray indexing, including the returned bounds. It fails on main and passes with this change. Full suite on Python 3.13 with xarray 2026.12.0: 302 passed, 1 skipped. Ruff check and format checks passed for the changed files.

Codex assisted with the implementation, tests, and PR description.

This branch has not been deployed

No deployments
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.

exclude bounds variables in methods

1 participant