diff options
author | Paulo Almeida <pcca24102002@gmail.com> | 2023-04-11 07:38:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 09:38:03 +0200 |
commit | fe893743b83173b72648dc79d86eda905230d1e9 (patch) | |
tree | 1667f85fe190d1158fc7583ea96eb404a5db100e /numpy/random/tests | |
parent | 34417a5d3470dc143ccd6935057b25b045306b49 (diff) | |
download | numpy-fe893743b83173b72648dc79d86eda905230d1e9.tar.gz |
BUG: accept zeros on numpy.random dirichlet function (#23440)
Changed alpha value error to pass a null value. This way, dirichlet function (on the generator, not mtrand) won't raise a value exception at 0. Also added test.
Diffstat (limited to 'numpy/random/tests')
-rw-r--r-- | numpy/random/tests/test_randomstate.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/random/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py index 8b911cb3a..3a2961098 100644 --- a/numpy/random/tests/test_randomstate.py +++ b/numpy/random/tests/test_randomstate.py @@ -812,6 +812,10 @@ class TestRandomDist: alpha = np.array([5.4e-01, -1.0e-16]) assert_raises(ValueError, random.dirichlet, alpha) + def test_dirichlet_zero_alpha(self): + y = random.default_rng().dirichlet([5, 9, 0, 8]) + assert_equal(y[2], 0) + def test_dirichlet_alpha_non_contiguous(self): a = np.array([51.72840233779265162, -1.0, 39.74494232180943953]) alpha = a[::2] |