summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/tests
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2011-08-27 21:46:08 -0600
committerCharles Harris <charlesr.harris@gmail.com>2011-08-27 21:46:08 -0600
commit9ecd91b7bf8c77d696ec9856ba10896d8f60309a (patch)
tree9884131ece5eada06212538c591965bf5928afa2 /numpy/matrixlib/tests
parentaa55ba7437fbe6b8772a360a641b5aa7d3e669e0 (diff)
parent10fac981763e87f949bed15c66127fc380fa9b27 (diff)
downloadnumpy-9ecd91b7bf8c77d696ec9856ba10896d8f60309a.tar.gz
Merge branch 'pull-141'
* pull-141: (167 commits) ENH: missingdata: Make PyArray_Converter and PyArray_OutputConverter safer for legacy code DOC: missingdata: Add a mention of the design NEP, and masks vs bitpatterns DOC: missingdata: Updates from pull request feedback DOC: missingdata: Updates based on pull request feedback ENH: nditer: Change the Python nditer exposure to automatically add NPY_ITER_USE_MASKNA ENH: missingdata: Make comparisons with NA return NA(dtype='bool') BLD: core: onefile build fix and Python3 compatibility change DOC: Mention the update to np.all and np.any in the release notes TST: dtype: Adjust void dtype test to pass without raising a zero-size exception STY: Remove trailing whitespace TST: missingdata: Write some tests for the np.any and np.all NA behavior ENH: missingdata: Make numpy.all follow the NA && False == False rule ENH: missingdata: Make numpy.all follow the NA || True == True rule DOC: missingdata: Also show what assigning a non-NA value does in each case DOC: missingdata: Add introductory documentation for NA-masked arrays ENH: core: Rename PyArrayObject_fieldaccess to PyArrayObject_fields DOC: missingdata: Some tweaks to the NA mask documentation DOC: missingdata: Add example of a C-API function supporting NA masks DOC: missingdata: Documenting C API for NA-masked arrays ENH: missingdata: Finish adding C-API access to the NpyNA object ...
Diffstat (limited to 'numpy/matrixlib/tests')
-rw-r--r--numpy/matrixlib/tests/test_defmatrix.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py
index 09a4b4892..0a181fca3 100644
--- a/numpy/matrixlib/tests/test_defmatrix.py
+++ b/numpy/matrixlib/tests/test_defmatrix.py
@@ -65,29 +65,45 @@ class TestProperties(TestCase):
sumall = 30
assert_array_equal(sum0, M.sum(axis=0))
assert_array_equal(sum1, M.sum(axis=1))
- assert_(sumall == M.sum())
+ assert_equal(sumall, M.sum())
+
+ assert_array_equal(sum0, np.sum(M, axis=0))
+ assert_array_equal(sum1, np.sum(M, axis=1))
+ assert_equal(sumall, np.sum(M))
def test_prod(self):
x = matrix([[1,2,3],[4,5,6]])
- assert_(x.prod() == 720)
- assert_(all(x.prod(0) == matrix([[4,10,18]])))
- assert_(all(x.prod(1) == matrix([[6],[120]])))
+ assert_equal(x.prod(), 720)
+ assert_equal(x.prod(0), matrix([[4,10,18]]))
+ assert_equal(x.prod(1), matrix([[6],[120]]))
+
+ assert_equal(np.prod(x), 720)
+ assert_equal(np.prod(x, axis=0), matrix([[4,10,18]]))
+ assert_equal(np.prod(x, axis=1), matrix([[6],[120]]))
y = matrix([0,1,3])
assert_(y.prod() == 0)
def test_max(self):
x = matrix([[1,2,3],[4,5,6]])
- assert_(x.max() == 6)
- assert_(all(x.max(0) == matrix([[4,5,6]])))
- assert_(all(x.max(1) == matrix([[3],[6]])))
+ assert_equal(x.max(), 6)
+ assert_equal(x.max(0), matrix([[4,5,6]]))
+ assert_equal(x.max(1), matrix([[3],[6]]))
+
+ assert_equal(np.max(x), 6)
+ assert_equal(np.max(x, axis=0), matrix([[4,5,6]]))
+ assert_equal(np.max(x, axis=1), matrix([[3],[6]]))
def test_min(self):
x = matrix([[1,2,3],[4,5,6]])
- assert_(x.min() == 1)
- assert_(all(x.min(0) == matrix([[1,2,3]])))
- assert_(all(x.min(1) == matrix([[1],[4]])))
+ assert_equal(x.min(), 1)
+ assert_equal(x.min(0), matrix([[1,2,3]]))
+ assert_equal(x.min(1), matrix([[1],[4]]))
+
+ assert_equal(np.min(x), 1)
+ assert_equal(np.min(x, axis=0), matrix([[1,2,3]]))
+ assert_equal(np.min(x, axis=1), matrix([[1],[4]]))
def test_ptp(self):
x = np.arange(4).reshape((2,2))