@@ -2597,6 +2597,34 @@ def test_nan_behavior(self):
25972597 assert_equal (np .median (a , (0 , 2 )), b )
25982598 assert_equal (len (w ), 1 )
25992599
2600+ def test_empty (self ):
2601+ # empty arrays
2602+ a = np .array ([], dtype = float )
2603+ with warnings .catch_warnings (record = True ) as w :
2604+ warnings .filterwarnings ('always' , '' , RuntimeWarning )
2605+ assert_equal (np .median (a ), np .nan )
2606+ assert_ (w [0 ].category is RuntimeWarning )
2607+
2608+ # multiple dimensions
2609+ a = np .array ([], dtype = float , ndmin = 3 )
2610+ # no axis
2611+ with warnings .catch_warnings (record = True ) as w :
2612+ warnings .filterwarnings ('always' , '' , RuntimeWarning )
2613+ assert_equal (np .median (a ), np .nan )
2614+ assert_ (w [0 ].category is RuntimeWarning )
2615+
2616+ # axis 0 and 1
2617+ b = np .array ([], dtype = float , ndmin = 2 )
2618+ assert_equal (np .median (a , axis = 0 ), b )
2619+ assert_equal (np .median (a , axis = 1 ), b )
2620+
2621+ # axis 2
2622+ b = np .array (np .nan , dtype = float , ndmin = 2 )
2623+ with warnings .catch_warnings (record = True ) as w :
2624+ warnings .filterwarnings ('always' , '' , RuntimeWarning )
2625+ assert_equal (np .median (a , axis = 2 ), b )
2626+ assert_ (w [0 ].category is RuntimeWarning )
2627+
26002628 def test_object (self ):
26012629 o = np .arange (7. )
26022630 assert_ (type (np .median (o .astype (object ))), float )
0 commit comments