summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@gmail.com>2018-04-23 17:03:15 -0700
committerGitHub <noreply@github.com>2018-04-23 17:03:15 -0700
commitac76793dafcd6e5f24ed052fc40413f29ebc5306 (patch)
treee5eed404c59488c4df688e4428fccb4d5afbad84 /numpy/lib/tests/test_function_base.py
parenta043c3ed2a08fc42fd2eff6669a862c5cb045bfc (diff)
parent5d5c379ed5af0df19eec68fdde1f87ad994ce6b1 (diff)
downloadnumpy-ac76793dafcd6e5f24ed052fc40413f29ebc5306.tar.gz
Merge pull request #10199 from chunweiyuan/quantile
ENH: Quantile
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 6653b5ba1..43d62a7ff 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2749,6 +2749,28 @@ class TestPercentile(object):
a, [0.3, 0.6], (0, 2), interpolation='nearest'), b)
+class TestQuantile(object):
+ # most of this is already tested by TestPercentile
+
+ def test_basic(self):
+ x = np.arange(8) * 0.5
+ assert_equal(np.quantile(x, 0), 0.)
+ assert_equal(np.quantile(x, 1), 3.5)
+ assert_equal(np.quantile(x, 0.5), 1.75)
+
+ def test_no_p_overwrite(self):
+ # this is worth retesting, beause quantile does not make a copy
+ p0 = np.array([0, 0.75, 0.25, 0.5, 1.0])
+ p = p0.copy()
+ np.quantile(np.arange(100.), p, interpolation="midpoint")
+ assert_array_equal(p, p0)
+
+ p0 = p0.tolist()
+ p = p.tolist()
+ np.quantile(np.arange(100.), p, interpolation="midpoint")
+ assert_array_equal(p, p0)
+
+
class TestMedian(object):
def test_basic(self):