diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-07-07 04:32:00 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-07-07 04:32:00 +0000 |
commit | 8bb282307481e208f972a72c5745c63e2404cd66 (patch) | |
tree | 31d7f1f3ff41423e5d0d90ba20b655072dc414b9 /numpy/lib/tests/test_function_base.py | |
parent | b1c994b77d851e49a1c62248b09aeaea5645fbdf (diff) | |
download | numpy-8bb282307481e208f972a72c5745c63e2404cd66.tar.gz |
ENH: Add ddof keyword to masked versions of cov and corrcoef.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 5d0f8aa45..037e8043a 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -821,30 +821,35 @@ class TestNanFunctsIntTypes(TestCase): class TestCorrCoef(TestCase): + A = array([[ 0.15391142, 0.18045767, 0.14197213], + [ 0.70461506, 0.96474128, 0.27906989], + [ 0.9297531 , 0.32296769, 0.19267156]]) + B = array([[ 0.10377691, 0.5417086 , 0.49807457], + [ 0.82872117, 0.77801674, 0.39226705], + [ 0.9314666 , 0.66800209, 0.03538394]]) + res1 = array([[ 1. , 0.9379533 , -0.04931983], + [ 0.9379533 , 1. , 0.30007991], + [-0.04931983, 0.30007991, 1. ]]) + res2 = array([[ 1. , 0.9379533 , -0.04931983, + 0.30151751, 0.66318558, 0.51532523], + [ 0.9379533 , 1. , 0.30007991, + - 0.04781421, 0.88157256, 0.78052386], + [-0.04931983, 0.30007991, 1. , + - 0.96717111, 0.71483595, 0.83053601], + [ 0.30151751, -0.04781421, -0.96717111, + 1. , -0.51366032, -0.66173113], + [ 0.66318558, 0.88157256, 0.71483595, + - 0.51366032, 1. , 0.98317823], + [ 0.51532523, 0.78052386, 0.83053601, + - 0.66173113, 0.98317823, 1. ]]) + def test_simple(self): - A = array([[ 0.15391142, 0.18045767, 0.14197213], - [ 0.70461506, 0.96474128, 0.27906989], - [ 0.9297531 , 0.32296769, 0.19267156]]) - B = array([[ 0.10377691, 0.5417086 , 0.49807457], - [ 0.82872117, 0.77801674, 0.39226705], - [ 0.9314666 , 0.66800209, 0.03538394]]) - assert_almost_equal(corrcoef(A), - array([[ 1. , 0.9379533 , -0.04931983], - [ 0.9379533 , 1. , 0.30007991], - [-0.04931983, 0.30007991, 1. ]])) - assert_almost_equal(corrcoef(A, B), - array([[ 1. , 0.9379533 , -0.04931983, - 0.30151751, 0.66318558, 0.51532523], - [ 0.9379533 , 1. , 0.30007991, - - 0.04781421, 0.88157256, 0.78052386], - [-0.04931983, 0.30007991, 1. , - - 0.96717111, 0.71483595, 0.83053601], - [ 0.30151751, -0.04781421, -0.96717111, - 1. , -0.51366032, -0.66173113], - [ 0.66318558, 0.88157256, 0.71483595, - - 0.51366032, 1. , 0.98317823], - [ 0.51532523, 0.78052386, 0.83053601, - - 0.66173113, 0.98317823, 1. ]])) + assert_almost_equal(corrcoef(self.A), self.res1) + assert_almost_equal(corrcoef(self.A, self.B), self.res2) + + def test_ddof(self): + assert_almost_equal(corrcoef(self.A, ddof=-1), self.res1) + assert_almost_equal(corrcoef(self.A, self.B, ddof=-1), self.res2) class Test_i0(TestCase): |