@@ -21,7 +21,6 @@ cdef inline uint64_t _gen_mask(uint64_t max_val) nogil:
2121 mask |= mask >> 16
2222 mask |= mask >> 32
2323 return mask
24-
2524{{
2625py:
2726bc_ctypes = (('uint32', 'uint32', 'uint64', 'NPY_UINT64', 0, 0, 0, '0X100000000ULL'),
@@ -32,11 +31,8 @@ bc_ctypes = (('uint32', 'uint32', 'uint64', 'NPY_UINT64', 0, 0, 0, '0X100000000U
3231 ('int16', 'uint16', 'uint32', 'NPY_INT32', 1, 16, '-0x8000LL', '0x8000LL' ),
3332 ('int8', 'uint8', 'uint16', 'NPY_INT16', 3, 8, '-0x80LL', '0x80LL' ),
3433)}}
35-
3634{{for nptype, utype, nptype_up, npctype, remaining, bitshift, lb, ub in bc_ctypes}}
37-
3835{{ py: otype = nptype + '_' if nptype == 'bool' else nptype }}
39-
4036cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *state, object lock):
4137 """
4238 _rand_{{nptype}}(low, high, size, *state, lock)
@@ -50,27 +46,27 @@ cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *st
5046
5147 Parameters
5248 ----------
53- low : int
49+ low : int or array-like
5450 Lowest (signed) integer to be drawn from the distribution (unless
5551 ``high=None``, in which case this parameter is the *highest* such
5652 integer).
57- high : int
53+ high : int or array-like
5854 If provided, the largest (signed) integer to be drawn from the
5955 distribution (see above for behavior if ``high=None``).
6056 size : int or tuple of ints
6157 Output shape. If the given shape is, e.g., ``(m, n, k)``, then
6258 ``m * n * k`` samples are drawn. Default is None, in which case a
6359 single value is returned.
64- rngstate : encapsulated pointer to rk_state
65- The specific type depends on the python version. In Python 2 it is
66- a PyCObject, in Python 3 a PyCapsule object.
60+ state : augmented random state
61+ State to use in the core random number generators
62+ lock : threading.Lock
63+ Lock to prevent multiple using a single RandomState simultaneously
6764
6865 Returns
6966 -------
7067 out : python scalar or ndarray of np.{{nptype}}
7168 `size`-shaped array of random integers from the appropriate
7269 distribution, or a single such random int if `size` not provided.
73-
7470 """
7571 cdef {{utype}}_t rng, last_rng, off, val, mask, out_val
7672 cdef uint32_t buf
@@ -150,45 +146,47 @@ cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *st
150146
151147 return out_arr
152148{{endfor}}
153-
154-
155149{{
156150py:
157151big_bc_ctypes = (('uint64', 'uint64', 'NPY_UINT64', '0x0ULL', '0xFFFFFFFFFFFFFFFFULL'),
158152 ('int64', 'uint64', 'NPY_INT64', '-0x8000000000000000LL', '0x7FFFFFFFFFFFFFFFLL' )
159153)}}
160-
161154{{for nptype, utype, npctype, lb, ub in big_bc_ctypes}}
162-
163155{{ py: otype = nptype}}
164-
165156cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *state, object lock):
166157 """
167- Generate bounded random {{nptype}} values
158+ _rand_{{nptype}}(low, high, size, *state, lock)
159+
160+ Return random np.{{nptype}} integers between `low` and `high`, inclusive.
161+
162+ Return random integers from the "discrete uniform" distribution in the
163+ closed interval [`low`, `high`). If `high` is None (the default),
164+ then results are from [0, `low`). On entry the arguments are presumed
165+ to have been validated for size and order for the np.{{nptype}} type.
168166
169167 Parameters
170168 ----------
171169 low : int or array-like
172- Array containing the lowest (signed) integers to be drawn from the
173- distribution.
170+ Lowest (signed) integer to be drawn from the distribution (unless
171+ ``high=None``, in which case this parameter is the *highest* such
172+ integer).
174173 high : int or array-like
175- Array containing the the open interval bound for the distribution.
174+ If provided, the largest (signed) integer to be drawn from the
175+ distribution (see above for behavior if ``high=None``).
176176 size : int or tuple of ints
177177 Output shape. If the given shape is, e.g., ``(m, n, k)``, then
178- ``m * n * k`` samples are drawn. Default is None, in which case
179- the output shape is determined by the broadcast shapes of low and
180- high
178+ ``m * n * k`` samples are drawn. Default is None, in which case a
179+ single value is returned.
181180 state : augmented random state
182181 State to use in the core random number generators
183182 lock : threading.Lock
184183 Lock to prevent multiple using a single RandomState simultaneously
185184
186185 Returns
187186 -------
188- out : ndarray of np.{{nptype}}
189- array of random integers from the appropriate distribution where the
190- size is determined by size if provided or the broadcast shape of low
191- and high
187+ out : python scalar or ndarray of np.{{nptype}}
188+ `size`-shaped array of random integers from the appropriate
189+ distribution, or a single such random int if `size` not provided.
192190 """
193191 cdef np.ndarray low_arr, high_arr, out_arr, highm1_arr
194192 cdef np.npy_intp i, cnt
@@ -279,5 +277,4 @@ cdef object _rand_{{nptype}}(object low, object high, object size, aug_state *st
279277 np.PyArray_MultiIter_NEXT(it)
280278
281279 return out_arr
282-
283280{{endfor}}
0 commit comments