From 633b11ca28e0c740215c4797db27363cde5246ba Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 17 Aug 2017 13:02:35 +0100 Subject: 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 --- numpy/random/tests/test_random.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/random/tests/test_random.py') 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)) -- cgit v1.2.1