Skip to content

UxDataset.isel() silently fails to slice when providing grid dim not in the dataset #1713

Description

@Sevans711

Version

v2026.8.0

How did you install UXarray?

Source

What happened?

Calling UxDataset.isel() to select along a grid dimension other than the grid dimension where the data is currently located successfully returns a UxDataset with the grid sliced properly, but the data not sliced at all. For example, for data with "n_face" dimension, slicing at n_edge=7 as mentioned in the docstring (added in #1684) leads to a result with uxgrid having only the two faces touching edge 7, but with "n_face" data dimension untouched.

I confirmed that this bug was not introduced by #1684; it exists on main even before that commit was merged. The behavior is inconsistent with UxDataArray.isel(), which instead also slices the "n_face" data dimension appropriately to keep the uxgrid and data in synch.

What did you expect to happen?

I expected the data to sliced appropriately such that the result's data contains precisely the edges/nodes/faces corresponding to the result's uxgrid.

Can you provide a MCVE to repoduce the bug?

import uxarray as ux
ds = ux.tutorial.open_dataset("outCSne30-vortex")
assert "n_face" in ds.dims
result = ds.isel(n_edge=7)
print((result.sizes["n_face"], result.uxgrid.n_face))
# expected (2, 2), got (5400, 2).

# Note: when using UxDataArray, there is no issue. This works just fine:
arr = ds["psi"]
result = arr.isel(n_edge=7)
print((result.sizes["n_face"], result.uxgrid.n_face))
# prints (2, 2) as expected.

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