BUG: Fixes #7395, operator.index now fails on numpy.bool_ by eric-wieser · Pull Request #9685 · numpy/numpy
Conversation
Rebase of @emilienkofman's #7420, along with added test and release notes. The description from there is
Attempt to fix the bug described in #7395. If this needs a depreciation warning I can change the Err to Warning and maybe add a test (?)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering about the one comment; less code is better...
| bool_index(PyObject *a) | ||
| { | ||
| return PyInt_FromLong(PyArrayScalar_VAL(a, Bool)); | ||
| PyErr_SetString(PyExc_TypeError, |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of raising an error here, isn't it easier to remove this whole definition and not define (or explicitly set to NULL; not sure) PyBoolArrType_Type.tp_as_number->nb_index? (it is currently defined in L4114).
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good catch
@mhvk: Addressed. Does this want a deprecation cycle? We already hit operator.index(array(True)) in a previous release
BvB93 pushed a commit to BvB93/numpy that referenced this pull request
Sep 7, 2020This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters