-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
randint over all of uint64 raises OverflowError if high=... is uint64 but not if it is int #9256
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
Comments
This is bizarre: >>> np.random.randint(np.uint64(0xfffffffffffffBFF), dtype=np.uint64)
10123822223749065263
>>> np.random.randint(np.uint64(0xfffffffffffffC00), dtype=np.uint64)
OverflowError: int too big to convert I don't think this bug is related to #8846 |
I don't see either problem. I take it this is windows? |
nope, OSX. |
I think this is fixed in master and 1.13.
|
@charris you are right. It seems fine under 1.13.0. Thanks for looking into it 👍 |
@vrtsig Note that 1.13.0 has other, new bugs that should get fixed in 1.13.1 |
@eric-wieser What platform are you on? |
1.12.1, but I think the fix in 1.13 is only coincidentally a solution, and there's likely a bug somewhere now morr hidden |
Yep, the issue originates in In particular, I think this might be a cython bug, and some problem converting from a I also think the changes in #8717 might help fix/hide the problem, by trying to avoid PyInt/int round-tripping |
I think you should try it with master/1.13. The fix changes the type of the arguments passed to the functions in |
You could probably look in the cython generated file. |
Seems to be mostly OK: In [31]: np.max(rs.randint(uint64_max, dtype=uint64,size=100000)) / 2 **64
Out[31]: 0.9999990152188338 |
@charris @eric-wieser This is fixed and can be closed. |
I ran into the following error with Windows (64bit), Python 3.6, numpy 1.15.4, distributed by EDM
(The same code does not fail on Linux nor OSX). @charris @eric-wieser Should this be re-opened or should I open a new issue? |
This is fixed in master |
Thank you @bashtage for your quick response. I am sorry for not having checked master before commenting. Just wanted to confirm, did you try this on Windows? |
This is not a bug. The default dtype is 'l', which is C long. On Windows 32 and 64 this is int32. If you use Try: np.random.RandomState(1).randint(np.iinfo(np.uint32).max, dtype='uint32')
Out[5]: 1791095845 or np.random.RandomState(1).randint(np.iinfo(np.int32).max, dtype='int32')
Out[5]: 1791095845 |
Stumbled over this earlier today:
Traceback:
conda 4.3.21
Python 3.5.3.final.0
numpy 1.12.1
osx-64 (El Capitan)
The text was updated successfully, but these errors were encountered: