summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorChun-Wei Yuan <cwyuan@ihmeadmins-MacBook-Pro-80.local>2018-01-16 15:11:42 -0800
committerChun-Wei Yuan <cwyuan@ihmeadminsMBP80.domain>2018-04-16 20:08:11 -0700
commit5d5c379ed5af0df19eec68fdde1f87ad994ce6b1 (patch)
tree00268716d827b7394efd825f7c24a9dcca3ba042 /numpy/lib/tests/test_function_base.py
parent3b79c4405690227087022a943fd78217b700a3f5 (diff)
downloadnumpy-5d5c379ed5af0df19eec68fdde1f87ad994ce6b1.tar.gz
ENH: Adding np.quantile() and np.nanquantile(). #10199
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 0a4c7c370..280715bc3 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2719,6 +2719,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):