summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-10-21 17:39:30 -0600
committerCharles Harris <charlesr.harris@gmail.com>2015-10-21 17:39:30 -0600
commitbf28b4432183126c21f0fa80852c335e9c1ed7c1 (patch)
tree23e923e507a9657204eb5338f3a06af4b8f281f1 /numpy/lib/tests
parent626eb3748d067ea6e4c4dd308252bfad97df186f (diff)
parent5caf4c932e43c47d73fad761e3257bb0d4551cc2 (diff)
downloadnumpy-bf28b4432183126c21f0fa80852c335e9c1ed7c1.tar.gz
Merge pull request #6527 from ethankruse/6462fix
Potential fix for #6462
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_function_base.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 4516c9248..cc53c2b8e 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2597,6 +2597,34 @@ class TestMedian(TestCase):
assert_equal(np.median(a, (0, 2)), b)
assert_equal(len(w), 1)
+ def test_empty(self):
+ # empty arrays
+ a = np.array([], dtype=float)
+ with warnings.catch_warnings(record=True) as w:
+ warnings.filterwarnings('always', '', RuntimeWarning)
+ assert_equal(np.median(a), np.nan)
+ assert_(w[0].category is RuntimeWarning)
+
+ # multiple dimensions
+ a = np.array([], dtype=float, ndmin=3)
+ # no axis
+ with warnings.catch_warnings(record=True) as w:
+ warnings.filterwarnings('always', '', RuntimeWarning)
+ assert_equal(np.median(a), np.nan)
+ assert_(w[0].category is RuntimeWarning)
+
+ # axis 0 and 1
+ b = np.array([], dtype=float, ndmin=2)
+ assert_equal(np.median(a, axis=0), b)
+ assert_equal(np.median(a, axis=1), b)
+
+ # axis 2
+ b = np.array(np.nan, dtype=float, ndmin=2)
+ with warnings.catch_warnings(record=True) as w:
+ warnings.filterwarnings('always', '', RuntimeWarning)
+ assert_equal(np.median(a, axis=2), b)
+ assert_(w[0].category is RuntimeWarning)
+
def test_object(self):
o = np.arange(7.)
assert_(type(np.median(o.astype(object))), float)