diff options
author | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2019-06-06 23:25:00 +0100 |
---|---|---|
committer | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2019-06-06 23:25:00 +0100 |
commit | f9f277da4ddb99d9b104289cf5c3df4b419c4f0d (patch) | |
tree | d31f540a0cd891609dcd0c8469a0838e85416213 /numpy | |
parent | 2834002b2b753c2438fa335298acc6815fcb1562 (diff) | |
download | numpy-f9f277da4ddb99d9b104289cf5c3df4b419c4f0d.tar.gz |
MAINT: Change wrap_int definition to use mask
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/random/common.pyx | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/numpy/random/common.pyx b/numpy/random/common.pyx index 8d992c8cf..6ad5f5b21 100644 --- a/numpy/random/common.pyx +++ b/numpy/random/common.pyx @@ -185,11 +185,8 @@ cdef double kahan_sum(double *darr, np.npy_intp n): cdef object wrap_int(object val, object bits): """Wraparound to place an integer into the interval [0, 2**bits)""" - upper = int(2)**int(bits) - if not 0<= val < upper: - divisor = val // upper - val = val - upper * divisor - return val + mask = ~(~int(0) << bits) + return val & mask cdef np.ndarray int_to_array(object value, object name, object bits, object uint_size): |