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

BUG: Change in handling of -1 in np.uint arrays between NumPy version 1.x and 2.x #18

Open
q-pratz-chem opened this issue Oct 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@q-pratz-chem
Copy link
Collaborator

q-pratz-chem commented Oct 31, 2024

Describe the problem:

An OverflowError was encountered while running the base.py script, where an attempt was made to generate the indices_multi NumPy array with type np.uint8 that included negative values. This behavior was observed to differ from that of NumPy version 1.22.4, Python 3.9.12, where the same operation was executed without issue.

Code that reproduces the bug:

import numpy as np
dict_ = {5: np.array([0, 4, -1, 6, 8, -8], dtype=np.uint8)}

Traceback error:

OverflowError: Python integer -1 out of bounds for uint8

Package versions:

python: 3.9.20
fanpy: 1.0.0
numpy: 2.0.2

Additonal comments

This issue appears to be related to the change in promotion rules for Python scalars in NumPy arrays between version 1.x and 2.x.

@q-pratz-chem q-pratz-chem added the bug Something isn't working label Oct 31, 2024
@q-pratz-chem
Copy link
Collaborator Author

NEP 50 — Promotion rules for Python scalars talks about the details of the change in promotion rules for Python Scalars.

In the case of the fanpy/wfn/cc/base.py, replacing np.uint with np.int seems to handle the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant