summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2010-05-16 08:31:03 +0000
committerStefan van der Walt <stefan@sun.ac.za>2010-05-16 08:31:03 +0000
commitccf308399107ec304b7e0d36692f9d929b6d3416 (patch)
treec5d44d55ff2841e699be38cf2bac6a088dff0946 /numpy/lib/tests/test_function_base.py
parent7c92f3237ec81e42d490d3b5eff89725608a112d (diff)
downloadnumpy-ccf308399107ec304b7e0d36692f9d929b6d3416.tar.gz
BUG: Correctly handle in-place output in percentile.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 4949eba5d..73fcc5621 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -968,7 +968,26 @@ def compare_results(res, desired):
def test_percentile_list():
- assert_equal(np.percentile([1,2,3], 0), 1)
+ assert_equal(np.percentile([1, 2, 3], 0), 1)
+
+def test_percentile_out():
+ x = np.array([1, 2, 3])
+ y = np.zeros((3,))
+ p = (1, 2, 3)
+ np.percentile(x, p, out=y)
+ assert_equal(y, np.percentile(x, p))
+
+ x = np.array([[1, 2, 3],
+ [4, 5, 6]])
+
+ y = np.zeros((3, 3))
+ np.percentile(x, p, axis=0, out=y)
+ assert_equal(y, np.percentile(x, p, axis=0))
+
+ y = np.zeros((3, 2))
+ np.percentile(x, p, axis=1, out=y)
+ assert_equal(y, np.percentile(x, p, axis=1))
+
if __name__ == "__main__":
run_module_suite()