Skip to content

random.randint failure with large int64s on windows #6812

Closed

Description

@jreback

clearly using platform ints internally. But I think this should upcast in the case of overflow?

In [21]: np.random.randint(np.iinfo(np.int32).min,np.iinfo(np.int32).max,10)
Out[21]:
array([ -397752718, -1983241147,  -920985850, -2131569981,  -769723972,
        -499680303,  1808795318,  -636996393, -1437760815,  1771191619])

In [22]: np.random.randint(np.iinfo(np.int64).min,np.iinfo(np.int64).max,10)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-22-3cceca91fd37> in <module>()
----> 1 np.random.randint(np.iinfo(np.int64).min,np.iinfo(np.int64).max,10)

mtrand.pyx in mtrand.RandomState.randint (numpy\random\mtrand\mtrand.c:10694)()

OverflowError: Python int too large to convert to C long

In [23]: np.__version__
Out[23]: '1.10.1'

Activity

  1. charris commented on Dec 11, 2015

    @charris
    Member

    Hmm, at least I don't think this is a regression ;) I suppose it comes down to using long long vs long somewhere.

  2. charris commented on Dec 11, 2015

    @charris
    Member

    I'm going to flag this as a wanted enhancement.

  3. jreback commented on Dec 11, 2015

    @jreback
    Author

    thanks @charris !

  4. gfyoung commented on Dec 12, 2015

    @gfyoung
    Contributor

    @charris : Indeed, long long vs. long is the case. PR is going up right now for that.

  5. gfyoung commented on Dec 18, 2015

    @gfyoung
    Contributor

    I might also add that this is not an issue for Windows in particular. It has to do with which distro of Python you are using. My guess is that you are using a 32-bit version, as I was able to replicate this issue on a 32-bit Ubuntu VM.

  6. added a commit that references this issue on Mar 22, 2016
    0ec21d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions