Skip to content

In UxDataset.isel() if "n_face" coords assigned: ValueError: dimension 'n_face' already exists as a scalar variable #1714

Description

@Sevans711

Version

v2026.8.0

How did you install UXarray?

Source

What happened?

When using isel() on UxDataset in a similar pattern as the workflow described in #1641, got strange ValueError (see title). This applies when using isel() on a UxDataset with coordinates assigned for n_face, which maybe isn't a central feature uxarray intends to support, but I also think this behavior shouldn't lead to a confusing crash. Similar workflow for UxDataArray works just fine.

What did you expect to happen?

I expected .isel() to select by index, and keep coordinates, without complaining about "n_face" having coordinates assigned to it, similarly to how it would work with xarray.Dataset.isel().

Can you provide a MCVE to repoduce the bug?

uxds = ux.tutorial.open_dataset("outCSne30-vortex")
uxds1 = uxds.assign_coords(n_face=np.arange(uxds.n_face.size))
uxds1.isel(n_face=[0,1,2])
# crashes with ValueError

# meanwhile, the following each work just fine, and behave how I would expect:
uxds1.to_xarray().isel(n_face=[0,1,2])

uxds1['psi'].isel(n_face=[0,1,2])

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