Skip to content

Clarify whether single-axis indices can be tuples i.e. x[(i,)] #257

Closed
@honno

Description

@honno

Currently numpy.array_api supports this behaviour. For example:

>>> x = xp.zeros(5)
>>> x[(0,)]
Array(0)

Also notably @asmeurer tests for (i,) indices in the compliance suite's multiaxis tests.

I can't work out whether the indexing rules specify this is allowed or not (i.e. not explicitly mentioned in either the single or multi-axis sections), but I would imagine this is expected. Before this was mentioned by @Zac-HD in HypothesisWorks/hypothesis#3065, I had just assumed that multi meant "one-or-more" and so this is allowed.

Let me know if I'm wrong and you can guarantee this with the current spec, although that raises the question if we could still purposely note this.

Clarification either way would be nice, but if this isn't actually agreed upon then I'd just add that allowing (i,) indices would make index tooling (like in Hypothesis) much simpler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions