summaryrefslogtreecommitdiff
path: root/numpy/random/tests/test_random.py
diff options
context:
space:
mode:
authorKevin Sheppard <kevin.k.sheppard@gmail.com>2017-08-17 13:02:35 +0100
committerKevin Sheppard <kevin.k.sheppard@gmail.com>2017-08-17 13:13:26 +0100
commit633b11ca28e0c740215c4797db27363cde5246ba (patch)
treed53a20c52bcdc891d2ba8e9b224b0c9c17749fdd /numpy/random/tests/test_random.py
parent26c79664d2edd48e1777cc4b31ecb952e2ec30d5 (diff)
downloadnumpy-633b11ca28e0c740215c4797db27363cde5246ba.tar.gz
BUG: Missing dirichlet input validation
Dirichlet does not validate inputs and hangs when values are zero. Adds check that values are strictly positive as required by the distribution. closes #2089
Diffstat (limited to 'numpy/random/tests/test_random.py')
-rw-r--r--numpy/random/tests/test_random.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index 3a1d8af51..39c45889f 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -525,6 +525,11 @@ class TestRandomDist(object):
assert_raises(TypeError, np.random.dirichlet, p, float(1))
+ def test_dirichlet_bad_alpha(self):
+ # gh-2089
+ alpha = np.array([5.4e-01, -1.0e-16])
+ assert_raises(ValueError, np.random.mtrand.dirichlet, alpha)
+
def test_exponential(self):
np.random.seed(self.seed)
actual = np.random.exponential(1.1234, size=(3, 2))