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

numpy >1.2 compatability #65

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

tr11-sanger
Copy link

Changed xp.bool to bool, as recommended by numpy

@vnmabus
Copy link
Owner

vnmabus commented Aug 31, 2024

I do not understand the reason for the change. I think in older NumPy versions, np.bool was an alias for bool (and maybe that is why it suggested that change). However, with more modern NumPy versions (>= 2.0.0 I think) np.bool is the actual dtype.

The problem with changing it to bool is that other array libraries may not support that as a dtype (they are not required to, according to the array API standard: https://data-apis.org/array-api/latest/API_specification/data_types.html). Thus, the code may not be portable across libraries that follow the standard.

@tr11-sanger
Copy link
Author

With numpy 1.26.0 I get the following error:

AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Sounds like it's not an issue with numpy>2.0.0 though

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants