diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-03-26 18:10:34 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-03-26 18:10:34 -0600 |
commit | 419cb15db0c4907082ab5327a7a9ec72b8e3d83c (patch) | |
tree | 4c1fae697f7d003b1eb5605e7d780c7576c5aa81 /numpy/lib/tests/test_function_base.py | |
parent | d35d5c1a1ff9cb9d60da54d8d1e6a66a042b0d27 (diff) | |
parent | e5cf3654e81573bf583cbf6a8688a5e44fafceea (diff) | |
download | numpy-419cb15db0c4907082ab5327a7a9ec72b8e3d83c.tar.gz |
Merge pull request #4542 from immerrr/fix-bincount-systemerror
BUG: fix some errors raised when minlength is incorrect in np.bincount
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 399a5a308..59db23a83 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -6,7 +6,7 @@ import numpy as np from numpy.testing import ( run_module_suite, TestCase, assert_, assert_equal, assert_array_equal, assert_almost_equal, assert_array_almost_equal, assert_raises, - assert_allclose, assert_array_max_ulp, assert_warns + assert_allclose, assert_array_max_ulp, assert_warns, assert_raises_regex ) from numpy.random import rand from numpy.lib import * @@ -1546,6 +1546,23 @@ class TestBincount(TestCase): y = np.bincount(x, minlength=5) assert_array_equal(y, np.zeros(5, dtype=int)) + def test_with_incorrect_minlength(self): + x = np.array([], dtype=int) + assert_raises_regex(TypeError, "an integer is required", + lambda: np.bincount(x, minlength="foobar")) + assert_raises_regex(ValueError, "must be positive", + lambda: np.bincount(x, minlength=-1)) + assert_raises_regex(ValueError, "must be positive", + lambda: np.bincount(x, minlength=0)) + + x = np.arange(5) + assert_raises_regex(TypeError, "an integer is required", + lambda: np.bincount(x, minlength="foobar")) + assert_raises_regex(ValueError, "minlength must be positive", + lambda: np.bincount(x, minlength=-1)) + assert_raises_regex(ValueError, "minlength must be positive", + lambda: np.bincount(x, minlength=0)) + class TestInterp(TestCase): def test_exceptions(self): |