Skip to content

.isel() modifies indexers dict, causing inconsistent behavior across repeated calls #1711

Closed

Description

@Sevans711

Version

v2026.8.0

How did you install UXarray?

Source

What happened?

When using UxDataArray.isel(indexers) or UxDataset.isel(indexers) with a pre-defined indexers dict, the dict itself is edited, so repeating the same .isel() code multiple times leads to different results.

What did you expect to happen?

I expected the indexers dict to not be modified directly.

The fix should be simple; inside .isel() methods, use a copy of indexers instead of popping grid_dim from the original.

Can you provide a MCVE to repoduce the bug?

obj = ux.tutorial.open_dataset('quad-hexagon')  # obj is a UxDataset
chosen_faces = {'n_face': 0}
resultA = obj.isel(chosen_faces)
resultB = obj.isel(chosen_faces)
print((resultA.sizes['n_face'], resultB.sizes['n_face']))
# expected (1, 1), got (1, 4)
print(chosen_faces)
# expected {'n_face': 0}, got {}

# same issue occurs with UxDataArray, e.g. try above with obj=obj['t2m']

Activity

  1. added
    bug
    on Aug 26, 2026
  2. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Aug 26, 2026
  3. self-assigned this
    on Aug 26, 2026
  4. moved this from 📝 To-Do to 🏗 In progress in UXarray Developmenton Sep 2, 2026
  5. moved this from 🏗 In progress to 👀 In review in UXarray Developmenton Sep 2, 2026
  6. moved this from 👀 In review to ✅ Done in UXarray Developmenton Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions