-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Scalar array comparison should return np.bool #27288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @eendebakpt the change LGTM (unrelated return changes are also fine). I doubt it will make issues, but maybe add a very short release note anyway? |
Arrg, I noticed one thing that maybe we should defer. But our scalars do the same dance and still return the Python boolean. Without any comments, I may just go ahead soon, but I want to let it sink in briefly for myself. |
Which scalar operations return the Python bool? I checked with
and they return a numpy bool. For the |
Ah, I guess only the ones for which the comparison is not defined |
Thanks. So we have:
This is not causing any issues (as far as i know), but it is a bit inconsistent. Note to self: python bool might be returned here numpy/numpy/_core/src/umath/scalarmath.c.src Line 1916 in 3ee9e6a
|
OK, thanks @eendebakpt let's give this a try. FWIW, we should of course return a 0-D array in some future (which this does not make any harder, I suspect it just means deleting the code branch completely). |
For scalar array comparison of different type such as
np.array(1) == np.array('s')
we return a numpy bool instead of a python bool.See #27271