summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authordhuard <dhuard@localhost>2008-03-14 16:17:44 +0000
committerdhuard <dhuard@localhost>2008-03-14 16:17:44 +0000
commit96bf0c7c4a5b31d0161cf899f1f7f35626bf0dc8 (patch)
treec635ae86b863a001ba7891ea628eea6bdc86d666 /numpy/lib/tests/test_function_base.py
parent6b3b8d4e5d32fd59bcd930e606ea89009df359b8 (diff)
downloadnumpy-96bf0c7c4a5b31d0161cf899f1f7f35626bf0dc8.tar.gz
Added a test for average. It uncovers a bug related to the shape of the weights.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 82aa5efb1..97601f968 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -63,6 +63,20 @@ class TestAverage(NumpyTestCase):
actual = average(y1,weights=[1,2],axis=0)
desired = array([3.,4.,5.])
assert_array_equal(actual, desired)
+
+ def check_shape(self):
+ y = array([[1,2,3],
+ [4,5,6]])
+
+ w2 = [[0,0,1],[0,0,1]]
+ desired = array([3., 6.])
+ assert_array_equal(average(y, weights=w2, axis=1), desired)
+
+ w1 = [0,0,1]
+ desired = array([3., 6.])
+ assert_array_equal(average(y, weights=w1, axis=1), desired)
+
+
class TestSelect(NumpyTestCase):
def _select(self,cond,values,default=0):