Skip to content

API: Readd np.bool_ typing stub #26210

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

Merged
merged 1 commit into from
Apr 8, 2024
Merged

API: Readd np.bool_ typing stub #26210

merged 1 commit into from
Apr 8, 2024

Conversation

mtsokol
Copy link
Member

@mtsokol mtsokol commented Apr 4, 2024

Fixes: #26199

Hi @seberg,

This PR adds np.bool_ typing alias for np.bool. I also found some remaining np.bool_ in tests.

@mtsokol mtsokol self-assigned this Apr 4, 2024
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Apr 4, 2024
@charris
Copy link
Member

charris commented Apr 6, 2024

There are a few other uses. The documentation simply uses the bool documentation for bool_, if we are trying to discourage use we should add a note for that. bool_ is also defined in _type_aliases.py, and used in numpy/_core/src/multiarray/scalartypes.c.src. My understanding is that we want to remove all internal usage, is that correct?

EDIT: or are we reserving bool_ for Python bool?

@rgommers
Copy link
Member

rgommers commented Apr 8, 2024

My understanding is that we want to remove all internal usage, is that correct?

I'd say yes. But that doesn't need to be backported to 2.0.x, and isn't urgent so I'd suggest doing that separately.

EDIT: or are we reserving bool_ for Python bool?

No, np.bool_ is an alias to np.bool and should disappear in the far future. We should not have any aliases for Python builtin types.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @mtsokol

@rgommers rgommers merged commit e43de40 into numpy:main Apr 8, 2024
@mtsokol mtsokol deleted the bool_-typing branch April 8, 2024 09:54
@mtsokol
Copy link
Member Author

mtsokol commented Apr 8, 2024

@charris I think all redundant usages of bool_ are already removed. bool_ is still present as an alias and can be used as np.bool_ or np.dtype("bool_"). The former requires "bool_" to be defined in _type_aliases.py. Once we drop bool_, both can be removed.

In scalartypes.c.src I agree, "|O:bool_" can be changed to "|O:bool". And in docs we can have another note about the bool -> bool_ change. I will fix both.

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.

BUG: np.bool_ alias not exported in __init__.pyi with 2.0.0rc1
3 participants