summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-08-18 20:44:24 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-08-18 20:44:24 -0600
commit0858d8a313d2fade35644ba1d1dbfb408041018f (patch)
treea69a2170fa57c5efac780a5fce8a192a9ad73d97 /numpy/lib/tests
parent3fe2744e6ff5e9027e01ebd166ae9bfd7aaaa309 (diff)
downloadnumpy-0858d8a313d2fade35644ba1d1dbfb408041018f.tar.gz
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.
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_nanfunctions.py38
1 files changed, 11 insertions, 27 deletions
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):