8000 randint output have different dtype on Linux and Windows · Issue #10317 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

randint output have different dtype on Linux and Windows #10317

@rth

Description

@rth

The output dtype of np.random.randint is not cross-platform compatible,

import numpy as np
np.random.randint(10, size=2).dtype

produces an array of int64 on Linux and an array of int32 on Windows.

Tested versions,

import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)

Linux

Linux-3.19.0-58-generic-x86_64-with-debian-jessie-sid
Python 3.6.3 |Anaconda, Inc.| (default, Nov 20 2017, 20:41:42)  [GCC 7.2.0]
NumPy 1.13.3

Windows

Windows-10-10.0.14393-SP0
Python 3.6.3 |Anaconda, Inc.| (default, Nov  8 2017, 15:10:56) [MSC v.1900 64 bit (AMD64)]
NumPy 1.13.3

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 setting dtype=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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0