Skip to content
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

API: Disallow strings in logical ufuncs #21142

Merged
merged 1 commit into from Mar 3, 2022

Conversation

charris
Copy link
Member

@charris charris commented Mar 2, 2022

Backport of #21024.

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 #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 numpygh-20898

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
@charris charris added 08 - Backport Used to tag backport PRs 30 - API labels Mar 2, 2022
@charris charris added this to the 1.22.3 release milestone Mar 2, 2022
@charris charris merged commit 19f6550 into numpy:maintenance/1.22.x Mar 3, 2022
@charris charris deleted the backport-21024 branch March 3, 2022 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants