diff options
author | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2019-05-28 10:35:57 +0100 |
---|---|---|
committer | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2019-05-28 23:53:52 +0100 |
commit | fbd9c515fcbf46b10e983067266272ca90c6d342 (patch) | |
tree | 3e4df1ce4a79e65dff5cda419e1185e564c77e26 /numpy/random/mtrand.pyx | |
parent | 22239d120f59826e8a2c758f4bee9893e835f511 (diff) | |
download | numpy-fbd9c515fcbf46b10e983067266272ca90c6d342.tar.gz |
BUG/MAINT: Disallow non-native byteorder in random ints
Warn that non-native byte order is not supported in randint and integers
closes #13159
Diffstat (limited to 'numpy/random/mtrand.pyx')
-rw-r--r-- | numpy/random/mtrand.pyx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx index f1d45668e..a1364ac18 100644 --- a/numpy/random/mtrand.pyx +++ b/numpy/random/mtrand.pyx @@ -606,9 +606,17 @@ cdef class RandomState: high = low low = 0 - key = np.dtype(dtype).name + dt = np.dtype(dtype) + key = dt.name if key not in _integers_types: raise TypeError('Unsupported dtype "%s" for randint' % key) + if not dt.isnative: + # numpy 1.17.0, 2019-05-28 + warnings.warn('Providing a dtype with a non-native byteorder is ' + 'not supported. If you require platform-independent ' + 'byteorder, call byteswap when required.\nIn future ' + 'version, providing byteorder will raise a ' + 'ValueError', DeprecationWarning) # Implementation detail: the use a masked method to generate # bounded uniform integers. Lemire's method is preferrable since it is @@ -4272,5 +4280,3 @@ __all__ = [ 'zipf', 'RandomState', ] - - |