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

Fix OverflowError: Python int too large to convert to C long #2000

Conversation

kounelisagis
Copy link
Member

The problem is related to https://numpy.org/neps/nep-0050-scalar-promotion.html#nep50.
Especially the fact that in numpy2 this behavior is not valid anymore:

>>> np.uint64(5) + -1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python integer -1 out of bounds for uint64

And we have to do this:

>>> np.uint64(5) + np.int64(-1)
np.float64(4.0)

I had made a fix when support for numpy2 was added, converting start,stop,step to np.int64, but this caused this overflow.

@kounelisagis
Copy link
Member Author

@jparismorgan could you confirm this fixes your original issue?

Copy link

@jparismorgan jparismorgan left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@kounelisagis kounelisagis merged commit 2df75c8 into dev Jul 5, 2024
34 checks passed
@kounelisagis kounelisagis deleted the agis/sc-50378/overflowerror-python-int-too-large-to-convert-to-c-long branch July 5, 2024 13:41
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