-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Open
Labels
Description
When record array is indexed with incorrect field name it raises ValueError as expected:
> arr = np.zeros(10, dtype=[('a', 'i8')])
> arr['b']
ValueError: no field of name bWhen a simple array is indexed, it raises IndexError as unexpected:
> arr = np.arange(10)
> arr['a']
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or
boolean arrays are valid indicesAccording to this question on SO previously it was ValueError in both cases. Because you can not typecheck, they are both ndarrays, it is odd to have different types of exceptions.
Was this an intended change?
Also according to all this, the message for IndexError is not full, it does not say about fields.