Skip to content

isel() fails with slice object, in UxDataArray and UxDataset #1639

Closed

Description

@Sevans711

Version

v2026.7.0

How did you install UXarray?

Source

What happened?

Slicing UxDataArray or UxDataset using .isel() and providing a slice object fails with TypeError: int() argument must be a string, a bytes-like object or a real number, not 'slice'.

What did you expect to happen?

I expected .isel() to properly select the indicated indices even when a slice object is used to indicate them.

Combining .isel() with .plot() seems like a decent way to visualize "which faces are which?" For example, I might use uxarr.isel(n_face=slice(0, 100, 5)) to understand how faces 0, 5, 10, ... are laid out in the grid.

Can you provide a MCVE to repoduce the bug?

import uxarray as ux
ds = ux.tutorial.open_dataset("outCSne30-vortex")
ds.isel(n_face=slice(None, None, 10))  # should get every 10th face.
# but actually, crashes with TypeError.

arr = ds['psi']
arr.isel(n_face=slice(2, 15, 3))  # should get faces 2, 5, 8, 11, 14
# but actually, crashes with TypeError.

# maybe helpful to note, the following seems to work just fine:
arr.isel(n_face=[2,5,8,11,14])

Activity

  1. added
    bug
    on Aug 3, 2026
  2. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Aug 13, 2026
  3. self-assigned this
    on Aug 28, 2026
  4. moved this from 📝 To-Do to 🏗 In progress in UXarray Developmenton Sep 2, 2026
  5. Sevans711 commented on Sep 2, 2026

    @Sevans711
    CollaboratorAuthor

    Update: discovered that this bug only applies when providing slice object for "n_face" indexer (regardless of data location).

    For example, the following works just fine:

    arr = ux.tutorial.open_dataset("outCSne30-vortex")['psi']
    arr.isel(n_node=slice(None, None, 100))
    arr.isel(n_edge=slice(None, None, 100))

    (Not showing UxDataset in example here because slicing UxDataset by a dimension which is not one of the data dimensions is currently bugged, as reported in #1713, and this example has data along dimension "n_face".)

  6. moved this from 🏗 In progress to 👀 In review in UXarray Developmenton Sep 2, 2026
  7. 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