Support slices when using the tuple renaming shortcut in `sel`/`isel`?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What is your issue?
I generally want indexed objects to have different dimension names than their original ones, so index quite often with .sel(original_dim_name=("new_dim_name", indexing_array)) instead of creating a dataarray for indexing_array with "new_dim_name" as dimension.
This doesn't seem to work with slice objects though: .sel(original_dim_name=("new_dim_name", slice(4, None, 2))) errors out with
ValueError: Variable None: Could not convert tuple of form (dims, data[, attrs, encoding]): ('new_dim_name', slice(4, None, 2)) to Variable.
I am not sure if the tuple syntax is discouraged and should be avoided altogether or if it would be possible to support that. From the error message and the indexing rules it seems whichever implementation actually happens for the conversion of slices into arrays could kick in for the 2nd element in the case of tuples and before the creation of the Variable object in order to support this case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the sel/isel indexing entry points and review the linked indexing rules, then reproduce the tuple-renaming case with slice(4, None, 2). Done means the tuple form accepts slices without the Variable conversion error and preserves the requested new dimension name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100