From f72c60510a225f242a36cdbbc3aacf1b36f05f22 Mon Sep 17 00:00:00 2001 From: David Warde-Farley Date: Fri, 7 Jan 2011 13:36:18 -0500 Subject: ENH: Add minlength keyword to bincount. Patch from ticket #1595. --- numpy/lib/tests/test_function_base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'numpy/lib/tests/test_function_base.py') diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 4df13e5f9..700798e76 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1026,6 +1026,21 @@ class TestBincount(TestCase): y = np.bincount(x, w) assert_array_equal(y, np.array([0, 0.2, 0.5, 0, 0.5, 0.1])) + def test_with_minlength(self): + x = np.array([0, 1, 0, 1, 1]) + y = np.bincount(x, minlength=3) + assert_array_equal(y, np.array([2, 3, 0])) + + 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])) + + def test_with_minlength_and_weights(self): + x = np.array([1, 2, 4, 5, 2]) + w = np.array([0.2, 0.3, 0.5, 0.1, 0.2]) + y = np.bincount(x, w, 8) + assert_array_equal(y, np.array([0, 0.2, 0.5, 0, 0.5, 0.1, 0, 0])) class TestInterp(TestCase): def test_exceptions(self): -- cgit v1.2.1