Inplace update fails with Implicit naming of numpy indexers
Open
Nobody has claimed this yet.
topic-error reporting
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What happened?
import xarray as xr
x = xr.DataArray(np.zeros((2, 3)), dims=("a", "b"))
assert x[("b", np.array([0, 1, 0])),].shape == (3,)
x[("b", np.array([0, 1, 0])),] += 1 # ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
Under the hood, this ends up being called, which fails:
x.variable[("b", np.array([0, 1, 0])),]
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 with the minimal reproducer and the x.variable[...] indexing path shown in the issue. Verify that the implicit NumPy indexer works for the inplace += case without the ValueError, while preserving the asserted (3,) shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100