Describe the issue:
When slicing an array with an invalid object, like a list, the exception text is:
"IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices"
which is generated on line 606 of _core/src/multiarray/mapping.c.
This was appropriate when lists of indices were accepted or detected as deprecated, but is misleading now. Would it be better to report something like the following:
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None), tuples of these objects, and integer or boolean arrays are valid indices
Reproduce the code example:
import numpy
myarray = numpy.zeros((5,5))
# generates misleading exception
slice = myarray[[slice(None),slice(None)]]
# correct
slice = myarray[(slice(None),slice(None))]
Error message:
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
Python and NumPy Versions:
Python version: all
Numpy version: all up to current main branch (commit 20185fd).
Runtime Environment:
No response
Context for the issue:
Seeing the exception, especially debugging legacy code that uses lists of slices, it's easy to waste time checking the individual indices, rather than the acutal indexing object.
Describe the issue:
When slicing an array with an invalid object, like a list, the exception text is:
"IndexError: only integers, slices (
:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices"which is generated on line 606 of _core/src/multiarray/mapping.c.
This was appropriate when lists of indices were accepted or detected as deprecated, but is misleading now. Would it be better to report something like the following:
IndexError: only integers, slices (
:), ellipsis (...), numpy.newaxis (None), tuples of these objects, and integer or boolean arrays are valid indicesReproduce the code example:
Error message:
Python and NumPy Versions:
Python version: all
Numpy version: all up to current main branch (commit 20185fd).
Runtime Environment:
No response
Context for the issue:
Seeing the exception, especially debugging legacy code that uses lists of slices, it's easy to waste time checking the individual indices, rather than the acutal indexing object.