MNT: remove some obsolete string to bool workarounds#31859
Open
ikrommyd wants to merge 4 commits into
Open
Conversation
count_nonzero to a one-liner
count_nonzero to a one-linernp.character branch for array conversion to boolean dtype in count_nonzero
np.character branch for array conversion to boolean dtype in count_nonzeroSigned-off-by: Iason Krommydas <[email protected]>
Signed-off-by: Iason Krommydas <[email protected]>
cca5338 to
809e62b
Compare
Signed-off-by: Iason Krommydas <[email protected]>
eendebakpt
reviewed
Jul 4, 2026
| else: | ||
| a_bool = a.astype(np.bool, copy=False) | ||
|
|
||
| a_bool = a.astype(np.bool, copy=False) |
Contributor
There was a problem hiding this comment.
asanyarray has a dtype and copy argument. Can this cast be combined with the previous line?
Contributor
Author
There was a problem hiding this comment.
Ah yeah with copy=None which is the default in asanyarray it should be equivalent. Done.
Signed-off-by: Iason Krommydas <[email protected]>
This 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Refactors an array conversion to boolean dtype in
count_nonzeroto a a one-liner.Just a small TODO I found while scrolling around the codebase.
This should work now given gh-9847 and the issue that superseded it gh-9875 are resolved and the extra
np.characterbranch should be unnecessary.Edit: I found a test that can be enabled too I think in
test_array_coercion.pyfor the same reason just by searching for these issue numbers in the codebaseFirst time committer introduction
N/A
AI Disclosure
No AI