summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_nanfunctions.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-04-27 23:02:43 +0100
committerEric Wieser <wieser.eric@gmail.com>2017-04-29 03:13:19 +0100
commita77709c67051a1d19ed4caa83b0b7686ba22bfc4 (patch)
tree887f3d7e6bb671c8ef7449bf9af4f6cb598a7867 /numpy/lib/tests/test_nanfunctions.py
parentc607456d9eac8743e5280adeec5496fd2621ae6a (diff)
downloadnumpy-a77709c67051a1d19ed4caa83b0b7686ba22bfc4.tar.gz
BUG: Fix incorrect behavior of nanfunctions on object arrays
Fixes gh-8974 and gh-9008
Diffstat (limited to 'numpy/lib/tests/test_nanfunctions.py')
-rw-r--r--numpy/lib/tests/test_nanfunctions.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index 1678e1091..466ceefb5 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -152,6 +152,18 @@ class TestNanFunctions_MinMax(TestCase):
assert_(res != np.nan)
assert_(len(w) == 0)
+ def test_object_array(self):
+ arr = np.array([[1.0, 2.0], [np.nan, 4.0], [np.nan, np.nan]], dtype=object)
+ assert_equal(np.nanmin(arr), 1.0)
+ assert_equal(np.nanmin(arr, axis=0), [1.0, 2.0])
+
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter('always')
+ # assert_equal does not work on object arrays of nan
+ assert_equal(list(np.nanmin(arr, axis=1)), [1.0, 4.0, np.nan])
+ assert_(len(w) == 1, 'no warning raised')
+ assert_(issubclass(w[0].category, RuntimeWarning))
+
class TestNanFunctions_ArgminArgmax(TestCase):