Skip to content

MNT: remove some obsolete string to bool workarounds - #31859

Merged
ngoldbaum merged 5 commits into
numpy:mainfrom
ikrommyd:cleanup-count-nonzero
Jul 7, 2026
Merged

MNT: remove some obsolete string to bool workarounds#31859
ngoldbaum merged 5 commits into
numpy:mainfrom
ikrommyd:cleanup-count-nonzero

Conversation

@ikrommyd

@ikrommyd ikrommyd commented Jul 4, 2026

Copy link
Copy Markdown
Member

PR summary

Removes a couple of obsolete string to bool workarounds and updates a comment and adds a tiny bit of testing.

First time committer introduction

N/A

AI Disclosure

No AI

@ikrommyd ikrommyd changed the title MNT: a.astype(np.bool) should work not for count_nonzero MNT: minor refactor of array conversion to boolean dtype in count_nonzero to a one-liner Jul 4, 2026
@ikrommyd ikrommyd changed the title MNT: minor refactor of array conversion to boolean dtype in count_nonzero to a one-liner MNT: remove unnecessary np.character branch for array conversion to boolean dtype in count_nonzero Jul 4, 2026
@ikrommyd ikrommyd changed the title MNT: remove unnecessary np.character branch for array conversion to boolean dtype in count_nonzero MNT: remove some obsolete string to bool workarounds Jul 4, 2026
ikrommyd added 2 commits July 4, 2026 01:14
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
@ikrommyd
ikrommyd force-pushed the cleanup-count-nonzero branch from cca5338 to 809e62b Compare July 4, 2026 06:14
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Comment thread numpy/_core/numeric.py Outdated
else:
a_bool = a.astype(np.bool, copy=False)

a_bool = a.astype(np.bool, copy=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asanyarray has a dtype and copy argument. Can this cast be combined with the previous line?

@ikrommyd ikrommyd Jul 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah with copy=None which is the default in asanyarray it should theoretically be equivalent. Done.

Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Comment thread numpy/_core/numeric.py
Comment thread numpy/_core/tests/test_numeric.py Outdated
Comment thread numpy/_core/tests/test_numeric.py
@ikrommyd

ikrommyd commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@ngoldbaum I think I addressed all your review comments.

@ngoldbaum

Copy link
Copy Markdown
Member

Thanks @ikrommyd!

@ngoldbaum
ngoldbaum merged commit da679e7 into numpy:main Jul 7, 2026
110 of 113 checks passed
@ikrommyd
ikrommyd deleted the cleanup-count-nonzero branch July 7, 2026 23:11
@ikrommyd ikrommyd added the 09 - Backport-Candidate PRs tagged should be backported label Jul 7, 2026
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 10, 2026
charris added a commit that referenced this pull request Jul 10, 2026
MNT: remove some obsolete string to bool workarounds (#31859)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants