summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 8595c6b5c..178237c33 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -6,6 +6,8 @@ from numpy.lib import *
from numpy.core import *
from numpy import matrix, asmatrix
+import numpy as np
+
class TestAny(TestCase):
def test_basic(self):
y1 = [0,0,1,0]
@@ -852,6 +854,27 @@ class TestPiecewise(TestCase):
assert y.ndim == 0
assert y == 0
+class TestBincount(TestCase):
+ def test_simple(self):
+ y = np.bincount(np.arange(4))
+ assert_array_equal(y, np.ones(4))
+
+ def test_simple2(self):
+ y = np.bincount(np.array([1, 5, 2, 4, 1]))
+ assert_array_equal(y, np.array([0, 2, 1, 0, 1, 1]))
+
+ def test_simple_weight(self):
+ x = np.arange(4)
+ w = np.array([0.2, 0.3, 0.5, 0.1])
+ y = np.bincount(x, w)
+ assert_array_equal(y, w)
+
+ def test_simple_weight2(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)
+ assert_array_equal(y, np.array([0, 0.2, 0.5, 0, 0.5, 0.1]))
+
def compare_results(res,desired):
for i in range(len(desired)):
assert_array_equal(res[i],desired[i])