summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorDavid Warde-Farley <wardefar@iro.umontreal.ca>2011-01-07 13:36:18 -0500
committerCharles Harris <charlesr.harris@gmail.com>2011-01-10 20:30:44 -0700
commitf72c60510a225f242a36cdbbc3aacf1b36f05f22 (patch)
tree99e9aaaeefae2e854edb5bb0b9f92d0af969ae8c /numpy/lib/tests/test_function_base.py
parentd43668c6284bc5cef4da155dcca6800b003294b7 (diff)
downloadnumpy-f72c60510a225f242a36cdbbc3aacf1b36f05f22.tar.gz
ENH: Add minlength keyword to bincount. Patch from ticket #1595.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py15
1 files changed, 15 insertions, 0 deletions
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):