From 0858d8a313d2fade35644ba1d1dbfb408041018f Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 18 Aug 2013 20:44:24 -0600 Subject: DEP: Make nansum return 0 for all-NaN or empty axis. Make this happen and remove test parts dependent on numpy version < 1.9. Fixes test failures in numpy after 1.8 branch. --- numpy/lib/tests/test_nanfunctions.py | 38 +++++++++++------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'numpy/lib/tests/test_nanfunctions.py') diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py index 292ffdf7a..25f09275d 100644 --- a/numpy/lib/tests/test_nanfunctions.py +++ b/numpy/lib/tests/test_nanfunctions.py @@ -244,36 +244,20 @@ class TestNanFunctions_Sum(TestCase): with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') res = nansum([np.nan]*3, axis=None) - if np.__version__[:3] < '1.9': - assert_(np.isnan(res), 'result is not NaN') - assert_(len(w) == 1, 'no warning raised') - assert_(issubclass(w[0].category, FutureWarning)) - else: - assert_(res == 0, 'result is not 0') - assert_(len(w) == 0, 'warning raised') + assert_(res == 0, 'result is not 0') + assert_(len(w) == 0, 'warning raised') def test_empty(self): mat = np.zeros((0, 3)) - if np.__version__[:3] < '1.9': - tgt = [np.nan]*3 - res = nansum(mat, axis=0) - assert_equal(res, tgt) - tgt = [] - res = nansum(mat, axis=1) - assert_equal(res, tgt) - tgt = np.nan - res = nansum(mat, axis=None) - assert_equal(res, tgt) - else: - tgt = [0]*3 - res = nansum(mat, axis=0) - assert_equal(res, tgt) - tgt = [] - res = nansum(mat, axis=1) - assert_equal(res, tgt) - tgt = 0 - res = nansum(mat, axis=None) - assert_equal(res, tgt) + tgt = [0]*3 + res = nansum(mat, axis=0) + assert_equal(res, tgt) + tgt = [] + res = nansum(mat, axis=1) + assert_equal(res, tgt) + tgt = 0 + res = nansum(mat, axis=None) + assert_equal(res, tgt) class TestNanFunctions_MeanVarStd(TestCase): -- cgit v1.2.1