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
BUG: Vague error message from ufunc np.any
#20898
Comments
Hmmm, it now behaves like |
At least from a user perspective, it wasn't clear to me what was going wrong whereas the original error message this was clear |
We discussed this a bit (in the triage meeting), and settled on just rejecting strings explicitly for now, because this is a bit weird. |
This restores pre 1.22 NumPy behaviour for strings passed into logical ufuncs. Logical ufuncs should be able to cast inputs to booleans without modifying their results. Thus they do this now (in NumPy 1.22+). The problem is that string to bool casts are very strange in NumPy currently. This should be reverted/removed once string to bool casts are well defined. But until then, it seems more reasonable to just reject strings. Closes numpygh-20898
* API: Disallow strings in logical ufuncs This restores pre 1.22 NumPy behaviour for strings passed into logical ufuncs. Logical ufuncs should be able to cast inputs to booleans without modifying their results. Thus they do this now (in NumPy 1.22+). The problem is that string to bool casts are very strange in NumPy currently. This should be reverted/removed once string to bool casts are well defined. But until then, it seems more reasonable to just reject strings. Closes gh-20898 Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* API: Disallow strings in logical ufuncs This restores pre 1.22 NumPy behaviour for strings passed into logical ufuncs. Logical ufuncs should be able to cast inputs to booleans without modifying their results. Thus they do this now (in NumPy 1.22+). The problem is that string to bool casts are very strange in NumPy currently. This should be reverted/removed once string to bool casts are well defined. But until then, it seems more reasonable to just reject strings. Closes numpygh-20898 Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* API: Disallow strings in logical ufuncs This restores pre 1.22 NumPy behaviour for strings passed into logical ufuncs. Logical ufuncs should be able to cast inputs to booleans without modifying their results. Thus they do this now (in NumPy 1.22+). The problem is that string to bool casts are very strange in NumPy currently. This should be reverted/removed once string to bool casts are well defined. But until then, it seems more reasonable to just reject strings. Closes numpygh-20898 Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* API: Disallow strings in logical ufuncs This restores pre 1.22 NumPy behaviour for strings passed into logical ufuncs. Logical ufuncs should be able to cast inputs to booleans without modifying their results. Thus they do this now (in NumPy 1.22+). The problem is that string to bool casts are very strange in NumPy currently. This should be reverted/removed once string to bool casts are well defined. But until then, it seems more reasonable to just reject strings. Closes numpygh-20898 Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Describe the issue:
Noticed with NumPy 1.22 that the error message from
np.any
is a bit vague. However NumPy 1.21 has a clearer error message. Interestingly the error type raised changed fromTypeError
toValueError
.Reproduce the code example:
Error message:
The NumPy 1.22 error message is:
Compare this to the previous error message from NumPy 1.21, which was:
NumPy/Python version information:
The text was updated successfully, but these errors were encountered: