summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_nanfunctions.py
diff options
context:
space:
mode:
authorMarten van Kerkwijk <mhvk@astro.utoronto.ca>2014-04-22 20:08:47 -0400
committerMarten van Kerkwijk <mhvk@astro.utoronto.ca>2014-04-22 20:08:47 -0400
commitff459fd2dc3641486b35c672e0d48855669a13a5 (patch)
treea3f7855000d9093e56f3df640b3510e4becf6172 /numpy/lib/tests/test_nanfunctions.py
parent5348c0210dd02b53e5e0e042f56976c7cd2ae002 (diff)
downloadnumpy-ff459fd2dc3641486b35c672e0d48855669a13a5.tar.gz
Add tests using matrices
Diffstat (limited to 'numpy/lib/tests/test_nanfunctions.py')
-rw-r--r--numpy/lib/tests/test_nanfunctions.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index df332dfb1..f00aa0165 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -114,6 +114,31 @@ class TestNanFunctions_MinMax(TestCase):
assert_(res.shape == (3, 1))
res = f(mat)
assert_(np.isscalar(res))
+ # check that rows of nan are dealt with for subclasses (#4628)
+ mat[1] = np.nan
+ for f in self.nanfuncs:
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter('always')
+ res = f(mat, axis=0)
+ assert_(isinstance(res, np.matrix))
+ assert_(not np.any(np.isnan(res)))
+ assert_(len(w) == 0)
+
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter('always')
+ res = f(mat, axis=1)
+ assert_(isinstance(res, np.matrix))
+ assert_(np.isnan(res[1, 0]) and not np.isnan(res[0, 0])
+ and not np.isnan(res[2, 0]))
+ assert_(len(w) == 1, 'no warning raised')
+ assert_(issubclass(w[0].category, RuntimeWarning))
+
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter('always')
+ res = f(mat)
+ assert_(np.isscalar(res))
+ assert_(res != np.nan)
+ assert_(len(w) == 0)
class TestNanFunctions_ArgminArgmax(TestCase):