summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorAntony Lee <anntzer.lee@gmail.com>2016-12-05 18:20:40 -0800
committerAntony Lee <anntzer.lee@gmail.com>2017-03-24 23:50:59 -0700
commitec6d4295a80e5df235d3f5445e6425581309c930 (patch)
tree2e4cceaef48676d61c8fa3062cbf34ec96b8a9cb /numpy/lib/tests/test_function_base.py
parentb297cb7eaeebbd6c66ea263fc5da61d43c4b01b8 (diff)
downloadnumpy-ec6d4295a80e5df235d3f5445e6425581309c930.tar.gz
ENH: Allow bincount(..., minlength=0).
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py15
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 5c2446e50..3f17a3c32 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2369,11 +2369,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])
@@ -2397,22 +2402,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):