@@ -368,26 +368,11 @@ cdef class RandomGenerator:
368
368
[ True, True]]])
369
369
370
370
"""
371
- cdef np .npy_intp n
372
- cdef np .ndarray randoms
373
- cdef int64_t * randoms_data
374
-
375
- if size is None :
376
- with self .lock :
377
- return random_positive_int (self ._brng )
378
-
379
- randoms = < np .ndarray > np .empty (size , dtype = np .int64 )
380
- randoms_data = < int64_t * > np .PyArray_DATA (randoms )
381
- n = np .PyArray_SIZE (randoms )
382
-
383
- for i in range (n ):
384
- with self .lock , nogil :
385
- randoms_data [i ] = random_positive_int (self ._brng )
386
- return randoms
371
+ return self .randint (0 , np .iinfo (np .int ).max + 1 , dtype = np .int , size = size )
387
372
388
- def randint (self , low , high = None , size = None , dtype = int , use_masked = True ):
373
+ def randint (self , low , high = None , size = None , dtype = np . int64 , use_masked = True ):
389
374
"""
390
- randint(low, high=None, size=None, dtype='l ', use_masked=True)
375
+ randint(low, high=None, size=None, dtype='int64 ', use_masked=True)
391
376
392
377
Return random integers from `low` (inclusive) to `high` (exclusive).
393
378
@@ -661,9 +646,9 @@ cdef class RandomGenerator:
661
646
cdf /= cdf [- 1 ]
662
647
uniform_samples = self .random_sample (shape )
663
648
idx = cdf .searchsorted (uniform_samples , side = 'right' )
664
- idx = np .array (idx , copy = False ) # searchsorted returns a scalar
649
+ idx = np .array (idx , copy = False , dtype = np . int64 ) # searchsorted returns a scalar
665
650
else :
666
- idx = self .randint (0 , pop_size , size = shape )
651
+ idx = self .randint (0 , pop_size , size = shape , dtype = np . int64 )
667
652
else :
668
653
if size > pop_size :
669
654
raise ValueError ("Cannot take a larger sample than "
@@ -692,7 +677,7 @@ cdef class RandomGenerator:
692
677
n_uniq += new .size
693
678
idx = found
694
679
else :
695
- idx = self .permutation (pop_size )[:size ]
680
+ idx = ( self .permutation (pop_size )[:size ]). astype ( np . int64 )
696
681
if shape is not None :
697
682
idx .shape = shape
698
683
0 commit comments