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

Adding support for numpy 2 #132

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Conversation

prsabahrami
Copy link
Contributor

Adhering to NEP 50, np.can_cast no longer applies any value-based logic for 0-D arrays and NumPy scalars.

Using np.min_scalar_type(value), the data type with the smallest size and smallest scalar kind that can hold value is checked against dtype.

However, there is still another issue due to the below schema of numpy 2.0.0's promotion rules:
image

For example, in the case of casting np.int64(5) to np.int8 , np.min_scalar_type(np.int64(5)) returns np.uint8, and according to the diagram, np.uint8 can not be casted to np.int8. I have manually checked if value is of kind uint and dtype is of kind np.signedinteger and if the casting can safely happen.

Copy link
Member

@pavelzw pavelzw left a comment

Choose a reason for hiding this comment

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

Thanks!

pyproject.toml Outdated Show resolved Hide resolved
@pavelzw pavelzw added the enhancement New feature or request label Jul 14, 2024
Co-authored-by: Pavel Zwerschke <pavelzw@gmail.com>
@pavelzw pavelzw merged commit 576680c into Quantco:main Jul 15, 2024
19 of 20 checks passed
@prsabahrami
Copy link
Contributor Author

My pleasure!

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

Successfully merging this pull request may close these issues.

2 participants