diff options
| author | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2020-07-14 17:55:54 +0100 |
|---|---|---|
| committer | Kevin Sheppard <kevin.k.sheppard@gmail.com> | 2020-07-14 18:41:33 +0100 |
| commit | 89ecc557fc9205e06c9816ce2122f42e3adced02 (patch) | |
| tree | 2eae8341c782e8545ec95e9612b50f4b922dc1ac /numpy/random/tests/test_randomstate.py | |
| parent | 0f7e8316be0523c0e08f746aaf3ad53aca0c01a8 (diff) | |
| download | numpy-89ecc557fc9205e06c9816ce2122f42e3adced02.tar.gz | |
BUG: Validate output size in bin- and multinomial
Check that size is not being broadcast
closes #16833
Diffstat (limited to 'numpy/random/tests/test_randomstate.py')
| -rw-r--r-- | numpy/random/tests/test_randomstate.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/random/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py index edd7811bf..23dbbed6a 100644 --- a/numpy/random/tests/test_randomstate.py +++ b/numpy/random/tests/test_randomstate.py @@ -1989,3 +1989,13 @@ def test_integer_repeat(int_func): val = val.byteswap() res = hashlib.md5(val.view(np.int8)).hexdigest() assert_(res == md5) + + +def test_broadcast_size_error(): + # GH-16833 + with pytest.raises(ValueError): + random.binomial(1, [0.3, 0.7], size=(2, 1)) + with pytest.raises(ValueError): + random.binomial([1, 2], 0.3, size=(2, 1)) + with pytest.raises(ValueError): + random.binomial([1, 2], [0.3, 0.7], size=(2, 1)) |
