-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Change in bool type coersion? #16023
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
Comments
Dang, yes, booleans are so hopelessly inconsistent here, and I did not think of them, too bad we did not have tests for this :(. Aside from the point release change, which is very unfortunate... I somewhat think we should probably just put a |
While the legacy behaviour of casting strings to booleans by first converting the string to an integer is undersireable in general. It will require a Deprecation/FutureWarning to do the transition. Changing this accidentally was thus a regression. Closes numpygh-16023
Uh oh!
There was an error while loading. Please reload this page.
In all past versions of NumPy dating back at least a decade, using astype(bool) on a str of '0' obtained False and on any other integer as True. Now the result is always True.
Reproducing code example:
Before 1.18.3:
array([False, True], dtype=bool)
After 1.18.3:
array([True, True], dtype=bool)
Numpy/Python version information:
1.18.3 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
Other Thoughts
Seems to have been introduced by #15929. The prior behavior was logical, and saved execution time doing multiple type conversions.
The text was updated successfully, but these errors were encountered: