Skip to content

Legacy randint with low=2**32 does not reproduce NumPy <1.17 values #14189

Closed

Description

@mihaic

The legacy randint in NumPy 1.17.0 does not reproduce values from previous versions when low=2**32. I tested against 1.16.4 and 1.15.4. It does work for other values of low; I am showing 2**31 and 2**33 below. Same behavior with seed 1.

Reproducing code example:

In [1]: import sys, numpy as np; print(np.__version__, sys.version)             
1.17.0 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

In [2]: for exponent in range(31, 34): 
   ...:     r = np.random.RandomState(0) 
   ...:     print(exponent, r.randint(2**exponent, size=(3,))) 
   ...:                                                                         
31 [209652396 398764591 924231285]
32 [2546248239 3626093760 3684848379]
33 [2546248239 7921061056 7979815675]
In [1]: import sys, numpy as np; print(np.__version__, sys.version)             
1.16.4 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

In [2]: for exponent in range(31, 34): 
   ...:     r = np.random.RandomState(0) 
   ...:     print(exponent, r.randint(2**exponent, size=(3,))) 
   ...:                                                                         
31 [209652396 398764591 924231285]
32 [2357136044 2546248239 3071714933]
33 [2546248239 7921061056 7979815675]
In [1]: import sys, numpy as np; print(np.__version__, sys.version)             
1.15.4 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

In [2]: for exponent in range(31, 34): 
   ...:     r = np.random.RandomState(0) 
   ...:     print(exponent, r.randint(2**exponent, size=(3,))) 
   ...:                                                                         
31 [209652396 398764591 924231285]
32 [2357136044 2546248239 3071714933]
33 [2546248239 7921061056 7979815675]

Activity

  1. added a commit that references this issue on Aug 14, 2019
  2. mattip commented on Sep 12, 2019

    @mattip
    Member

    @bashtage ping. This seems like a regression in the legacy implementation

  3. added this to the 1.17.3 release milestone on Sep 12, 2019
  4. bashtage commented on Sep 13, 2019

    @bashtage
    Contributor

    Which OS are you on? Might matter since legacy used C long for integer types.

  5. bashtage commented on Sep 13, 2019

    @bashtage
    Contributor

    Worked out it is Linux since you can't use 2**33.

  6. bashtage commented on Sep 13, 2019

    @bashtage
    Contributor

    Fix is in bashtage/randomgen#184. Will port after it passes everywhere.

  7. added a commit that references this issue on Sep 15, 2019
    d9d620c
  8. removed
    09 - Backport-Candidate
    on Jul 19, 2020
  9. removed this from the 1.17.3 release milestone on Jul 19, 2020
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