From 1e659b5ab591d47449b73481f2335a7a850495b7 Mon Sep 17 00:00:00 2001 From: pierregm Date: Tue, 27 Apr 2010 16:55:09 +0000 Subject: Fixed .var for arrays with 1 more valid value than ddofs --- numpy/ma/tests/test_core.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'numpy/ma/tests') diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 014af2d73..f95d621db 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -199,7 +199,7 @@ class TestMaskedArray(TestCase): err_status_ini = np.geterr() try: np.seterr(invalid='ignore') - data = masked_array(np.sqrt([-1., 0., 1.]), mask=[0, 0, 1]) + data = masked_array([np.nan, 0., 1.], mask=[0, 0, 1]) data_fixed = fix_invalid(data) assert_equal(data_fixed._data, [data.fill_value, 0., 1.]) assert_equal(data_fixed._mask, [1., 0., 1.]) @@ -2707,6 +2707,19 @@ class TestMaskedArrayMathMethods(TestCase): self.assertTrue(np.isnan(nout)) + def test_varstd_ddof(self): + a = array([[1, 1, 0], [1, 1, 0]], mask=[[0, 0, 1], [0, 0, 1]]) + test = a.std(axis=0, ddof=0) + assert_equal(test.filled(0), [0, 0, 0]) + assert_equal(test.mask, [0, 0, 1]) + test = a.std(axis=0, ddof=1) + assert_equal(test.filled(0), [0, 0, 0]) + assert_equal(test.mask, [0, 0, 1]) + test = a.std(axis=0, ddof=2) + assert_equal(test.filled(0), [0, 0, 0]) + assert_equal(test.mask, [1, 1, 1]) + + def test_diag(self): "Test diag" x = arange(9).reshape((3, 3)) -- cgit v1.2.1