Registry Mirror
Skip to content

Conversation

@dcherian

@dcherian dcherian commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

CoordinateTransformIndexingAdapter._oindex_get did not drop axes indexed by an integer; only __getitem__ squeezed them. Dask reads chunks through ImplicitToExplicitIndexingAdapter(..., OuterIndexer), so after .chunk(...).isel(x=1, y=2), computing the scalar coord returned shape (1,) / (1, 1) and Dataset.load raised:

ValueError: replacement data must match the Variable's shape. replacement data has shape (1,); Variable has shape ()

Affects every CoordinateTransformIndex, e.g. RangeIndex:

idx = xr.indexes.RangeIndex.arange(0.0, 12.0, 1.0, dim="x")
da = xr.DataArray(np.ones((3, 12)), dims=("t", "x"), coords=xr.Coordinates.from_xindex(idx))
da.chunk(t=1).isel(x=3).compute()  # ValueError

Fix: squeeze integer axes in _oindex_get; __getitem__ now just calls it.

🤖 Generated with Claude Code

…ex_get

Only __getitem__ squeezed integer axes, so outer indexing with an
integer (as dask does when reading a chunk) returned shape (1,) instead
of (). Computing a chunked scalar coordinate then raised a shape error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcherian
dcherian force-pushed the fix-coord-transform-oindex-int branch from f699c18 to bcd8944 Compare October 6, 2026 16:34
@dcherian
dcherian marked this pull request as ready for review October 6, 2026 16:35
@dcherian dcherian added the plan to merge Final call for comments label Oct 6, 2026
@dcherian
dcherian merged commit 14ceb8d into pydata:main Oct 6, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan to merge Final call for comments topic-indexing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coordinates.from_xindex(RasterIndex) produces scalar coords with wrong shape after chunked nearest spatial selection

2 participants