diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-26 09:34:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-26 09:34:11 +0100 |
commit | 1a82adf443de8b95cc747f44c2363f793a8d4ad4 (patch) | |
tree | b784805162d0485a7af080245d967da387a18494 /numpy/lib/tests/test_function_base.py | |
parent | b7dc5193f7136f5b09f45c3fb10118556e961e74 (diff) | |
parent | ec6d4295a80e5df235d3f5445e6425581309c930 (diff) | |
download | numpy-1a82adf443de8b95cc747f44c2363f793a8d4ad4.tar.gz |
Merge pull request #8348 from anntzer/bincount-zero-minlength
ENH: Allow bincount(..., minlength=0).
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 188c1c2ea..708b20482 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2507,11 +2507,16 @@ class TestBincount(TestCase): x = np.array([0, 1, 0, 1, 1]) y = np.bincount(x, minlength=3) assert_array_equal(y, np.array([2, 3, 0])) + x = [] + y = np.bincount(x, minlength=0) + assert_array_equal(y, np.array([])) def test_with_minlength_smaller_than_maxvalue(self): x = np.array([0, 1, 1, 2, 2, 3, 3]) y = np.bincount(x, minlength=2) assert_array_equal(y, np.array([1, 2, 2, 2])) + y = np.bincount(x, minlength=0) + assert_array_equal(y, np.array([1, 2, 2, 2])) def test_with_minlength_and_weights(self): x = np.array([1, 2, 4, 5, 2]) @@ -2535,22 +2540,16 @@ class TestBincount(TestCase): "'str' object cannot be interpreted", lambda: np.bincount(x, minlength="foobar")) assert_raises_regex(ValueError, - "must be positive", + "must be non-negative", 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, "'str' object cannot be interpreted", lambda: np.bincount(x, minlength="foobar")) assert_raises_regex(ValueError, - "minlength must be positive", + "minlength must be non-negative", lambda: np.bincount(x, minlength=-1)) - assert_raises_regex(ValueError, - "minlength must be positive", - lambda: np.bincount(x, minlength=0)) @dec.skipif(not HAS_REFCOUNT, "python has no sys.getrefcount") def test_dtype_reference_leaks(self): |