summaryrefslogtreecommitdiff
path: root/numpy/random/tests/test_random.py
diff options
context:
space:
mode:
authorKevin Sheppard <kevin.sheppard@gmail.com>2020-12-04 23:03:23 +0000
committerKevin Sheppard <kevin.k.sheppard@gmail.com>2020-12-11 15:27:13 +0000
commit52ecd5a97ce3ff4dad72935b8bf67ba2cfb6908e (patch)
tree5561b20cf8b0190021275fc395fb52f46d096830 /numpy/random/tests/test_random.py
parentba596df4cc23445a117c3785239a75a3cab6b2f2 (diff)
downloadnumpy-52ecd5a97ce3ff4dad72935b8bf67ba2cfb6908e.tar.gz
BUG: Enforce high >= low on uniform number generators
Check that high is weakly larger than low and raise if now closes #17905
Diffstat (limited to 'numpy/random/tests/test_random.py')
-rw-r--r--numpy/random/tests/test_random.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index c13fc39e3..473ca08e4 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -916,6 +916,12 @@ class TestRandomDist:
# account for i386 extended precision DBL_MAX / 1e17 + DBL_MAX >
# DBL_MAX by increasing fmin a bit
np.random.uniform(low=np.nextafter(fmin, 1), high=fmax / 1e17)
+
+ def test_uniform_neg_range(self):
+ func = np.random.uniform
+ assert_raises(ValueError, func, 2, 1)
+ assert_raises(ValueError, func, [1, 2], [1, 1])
+ assert_raises(ValueError, func, [[0, 1],[2, 3]], 2)
def test_scalar_exception_propagation(self):
# Tests that exceptions are correctly propagated in distributions