Skip to content

np.bool_.__index__ should error #7395

@njsmith

Description

@njsmith

operator.index correctly raises an error on boolean arrays:

In [6]: operator.index(np.array(True))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-a4163d1794ac> in <module>()
----> 1 operator.index(np.array(True))

TypeError: only integer arrays with one element can be converted to an index

But on a boolean scalar, it incorrectly succeeds:

In [7]: operator.index(np.bool_(True))
Out[7]: 1

The latter should be an error (possibly with some deprecation period).

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