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/tests | |
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/tests')
-rw-r--r-- | numpy/random/tests/test_generator_mt19937.py | 4 | ||||
-rw-r--r-- | numpy/random/tests/test_randomstate_regression.py | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/numpy/random/tests/test_generator_mt19937.py b/numpy/random/tests/test_generator_mt19937.py index 192dcce08..64d87cd71 100644 --- a/numpy/random/tests/test_generator_mt19937.py +++ b/numpy/random/tests/test_generator_mt19937.py @@ -467,6 +467,10 @@ class TestIntegers(object): assert_equal(random.integers(0, -10, size=0).shape, (0,)) assert_equal(random.integers(10, 10, size=0).shape, (0,)) + def test_error_byteorder(self): + other_byteord_dt = '<i4' if sys.byteorder == 'big' else '>i4' + with pytest.raises(ValueError): + random.integers(0, 200, size=10, dtype=other_byteord_dt) class TestRandomDist(object): # Make sure the random distribution returns the correct value for a diff --git a/numpy/random/tests/test_randomstate_regression.py b/numpy/random/tests/test_randomstate_regression.py index 9c319319e..5bb1ddde5 100644 --- a/numpy/random/tests/test_randomstate_regression.py +++ b/numpy/random/tests/test_randomstate_regression.py @@ -1,4 +1,7 @@ import sys + +import pytest + from numpy.testing import ( assert_, assert_array_equal, assert_raises, ) @@ -155,3 +158,9 @@ class TestRegression(object): perm = random.permutation(m) assert_array_equal(perm, np.array([2, 1, 4, 0, 3])) assert_array_equal(m.__array__(), np.arange(5)) + + def test_warns_byteorder(self): + # GH 13159 + other_byteord_dt = '<i4' if sys.byteorder == 'big' else '>i4' + with pytest.deprecated_call(match='non-native byteorder is not'): + random.randint(0, 200, size=10, dtype=other_byteord_dt) |