Skip to content

Assigning through a bare Ellipsis index fails while reading works #4313

Closed

Description

@Adityaj0

Describe the bug

Assigning through a bare Ellipsis fails, even though reading through it works and every neighbouring form of assignment works:

ValueError: Cannot index mlx array using the given type.

mlx_get_item has an explicit Ellipsis branch:

// python/src/indexing.cpp
} else if (nb::isinstance<nb::ellipsis>(obj)) {
    return src;

mlx_compute_scatter_args has no matching branch, so a bare Ellipsis falls through the slice / array / int / tuple / None / list cases and hits the final throw.

Only the bare form is affected. Anything that puts the ellipsis inside a tuple takes the mlx_scatter_args_nd path and works fine.

To Reproduce

import mlx.core as mx

a = mx.zeros((2, 3))

a[...]           # fine
a[..., 0] = 5    # fine
a[0, ...] = 5    # fine
a[..., :] = 5    # fine
a[:] = 5         # fine
a[None] = 5      # fine

a[...] = 5
# ValueError: Cannot index mlx array using the given type.

NumPy:

>>> n = np.zeros((2, 3)); n[...] = 5; n
array([[5., 5., 5.],
       [5., 5., 5.]])

Expected behavior

a[...] = v should assign to the whole array, the same as a[:] = v and a[None] = v already do.

Desktop

  • OS Version: macOS 26.2
  • Version: main @ 8c28c38

Additional context

docs/src/usage/indexing.rst states that "the ... or :obj:Ellipsis syntax works as in NumPy", and its "Differences from NumPy" note lists exactly two deviations — no bounds checking, and boolean masks being assignment-only. This is not among them, and there is an "In Place Updates" section documenting indexed assignment, so this reads as an omission rather than an intended restriction.

Existing tests only cover Ellipsis inside a tuple (check_slices(..., Ellipsis, ...)) and a bare [...] read, which is why the gap survived.

I have a fix and tests ready and will link a PR.

Activity

  1. Adityaj0 commented on Aug 16, 2026

    @Adityaj0
    ContributorAuthor

    PR: #4314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions