From dce8638a727ea42ec97a407209ba0a722bf76380 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 29 Mar 2011 19:02:39 +0200 Subject: BUG: make np.median() work for 0-D arrays. Also add tests. Closes #1747. --- numpy/lib/tests/test_function_base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'numpy/lib/tests/test_function_base.py') diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index cf8429a84..6e80b0438 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1115,5 +1115,16 @@ def test_percentile_out(): assert_equal(y, np.percentile(x, p, axis=1)) +def test_median(): + a0 = np.array(1) + a1 = np.arange(2) + a2 = np.arange(6).reshape(2, 3) + assert_allclose(np.median(a0), 1) + assert_allclose(np.median(a1), 0.5) + assert_allclose(np.median(a2), 2.5) + assert_allclose(np.median(a2, axis=0), [1.5, 2.5, 3.5]) + assert_allclose(np.median(a2, axis=1), [1, 4]) + + if __name__ == "__main__": run_module_suite() -- cgit v1.2.1