Skip to content

isel() with xr.DataArray indexer along grid dimension fails to include indexer's coordinates in result #1712

Description

@Sevans711

Version

v2026.8.0

How did you install UXarray?

Source

What happened?

When using .isel() from a UxDataArray or UxDataset, and supplying an xr.DataArray as the indexer for a grid dimension, the xr.DataArray's coordinates are not included in the result.

What did you expect to happen?

I expected the xr.DataArray's coordinates to be included in the result where possible, consistently with xarray's behavior. See, e.g.: https://docs.xarray.dev/en/stable/user-guide/indexing.html#more-advanced-indexing

Can you provide a MCVE to repoduce the bug?

import uxarray as ux
obj = ux.tutorial.open_dataset('quad-hexagon')
result = obj.isel(n_face=xr.DataArray(0, coords={'newcoord': 7}))
print(result.coords)
# expected 'newcoord' to be in result.coords, but it was not.

# to see the corresponding xarray behavior, can try:
result = obj.to_xarray().isel(n_face=xr.DataArray(0, coords={'newcoord': 7}))
print(result.coords)
# (in this case, 'newcoord' is indeed in result.coords)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions