[BUG] `__setitem__` with a single Ellipsis fails
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 28.5k
- Forks
- 2.3k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 62
Description
Describe the bug
__setitem__ with a single ellipsis fails, while manually wrapping the ellipsis into a tuple makes it work.
To Reproduce
Include code snippet
>>> a = mx.arange(3)
>>> a[...] = 42
Traceback (most recent call last):
File "<python-input-29>", line 1, in <module>
a[...] = 42
~^^^^^
ValueError: Cannot index mlx array using the given type.
>>> a[(...,)] = 42
>>> a
array([42, 42, 42], dtype=int32)
Expected behavior
Expected a[...] to be equivalent to a[(Ellipsis,)], similar to indexing with a single integer or a slice: a[key] is a syntax sugar for a[(key,)] for key being an integer, a slice or the Ellipsis singleton.
Desktop (please complete the following information):
- OS Version: [e.g. MacOS 14.1.2]
- Version [e.g. 0.7.0]
$ sw_vers -productVersion
26.4.1
$ python -c'import mlx.core as mx; print(mx.__version__)'
0.32.1
Additional context
Add any other context about the problem here.
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 by reproducing the reported a[...] and a[(...,)] cases, then trace the array setitem path for a bare Ellipsis versus a tuple-wrapped key. Add a regression test showing both forms assign the same values, and confirm the test passes without changing the existing tuple behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100