diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-08-18 12:04:49 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-27 07:26:56 -0600 |
commit | c8732958c8e07f2306029dfde2178faf9c01d049 (patch) | |
tree | 3c5463cfa4bdd87e4873d30edab424ad9caf1511 /numpy | |
parent | e15712cf5df41806980f040606744040a433b331 (diff) | |
download | numpy-c8732958c8e07f2306029dfde2178faf9c01d049.tar.gz |
TST: missingdata: Finish up NA mask tests for np.std and np.var
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_maskna.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/core/tests/test_maskna.py b/numpy/core/tests/test_maskna.py index ad80f403d..e284f841b 100644 --- a/numpy/core/tests/test_maskna.py +++ b/numpy/core/tests/test_maskna.py @@ -1132,6 +1132,24 @@ def test_array_maskna_var_std(): res = np.std(a, axis=1) assert_array_almost_equal(res, [np.NA, 0.81649658092772603]) + # With an NA and skipna=True + a = np.arange(6, maskna=True).reshape(2,3) + a[0,1] = np.NA + + res = np.var(a, skipna=True) + assert_almost_equal(res, 2.96) + res = np.std(a, skipna=True) + assert_almost_equal(res, 1.7204650534085253) + + res = np.var(a, axis=0, skipna=True) + assert_array_equal(res, [2.25, 0, 2.25]) + res = np.std(a, axis=0, skipna=True) + assert_array_equal(res, [1.5, 0, 1.5]) + + res = np.var(a, axis=1, skipna=True) + assert_array_almost_equal(res, [1.0, 0.66666666666666663]) + res = np.std(a, axis=1, skipna=True) + assert_array_almost_equal(res, [1.0, 0.81649658092772603]) if __name__ == "__main__": run_module_suite() |