-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
randint output have different dtype on Linux and Windows #10317
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 8000 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A much simpler reproduction is
|
Probably quite much code assumes dtype(int).itemsize == sizeof(long),
so changing that looks quite breaking, possibly no-go.
|
There is no fundamental reason but the requirement for same inputs = same outputs (conditional on platform, compiler, etc.) means that this cannot be changed in the current |
The default was chosen for backwards compatibility, although it is already somewhat broken as it is OS dependent. The simplest solution is to explicitly specify the dtype. |
Note that these problems with the long C type are inherited from early Python before it became fully 64 bit compatible with Python 2.5. We were still supporting Python 2.4 as recently as 1.7 (2013). |
I understand, thank you for the explanations. |
Closing, please reopen if you wish to pursue changing this |
The output dtype of
np.random.randint
is not cross-platform compatible,produces an array of
int64
on Linux and an array ofint32
on Windows.Tested versions,
Linux
Windows
This is due to the fact that the default input parameter is
dtype='l'
. I saw that there was a lot of related discussion leading to #6910 but I was wondering if there were reasons that prevented settingdtype=np.int64
by default there.The current behaviour is problematic with any typed code (e.g. Cython / GPU related), and, for instance led to maciejkula/spotlight#82
cc @gfyoung @charris
The text was updated successfully, but these errors were encountered: