summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@googlemail.com>2011-03-29 19:02:39 +0200
committerRalf Gommers <ralf.gommers@googlemail.com>2011-03-29 19:02:39 +0200
commitdce8638a727ea42ec97a407209ba0a722bf76380 (patch)
tree116e1fa20f64671a331272a00f67bd9c8fc89528 /numpy/lib/tests/test_function_base.py
parenta6c2ac7f6312b3e8e553c548f2939405e16e44a6 (diff)
downloadnumpy-dce8638a727ea42ec97a407209ba0a722bf76380.tar.gz
BUG: make np.median() work for 0-D arrays. Also add tests. Closes #1747.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py11
1 files changed, 11 insertions, 0 deletions
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()