diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-04-24 18:18:37 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-24 18:18:37 -0600 |
commit | 246ad1dd3006ed4230a5c457838450f96df755e7 (patch) | |
tree | 11b34c7d834d2bd11503441aa8253c4618988866 /numpy/lib/tests/test_function_base.py | |
parent | 86608c2883b9f1db468bf6d3b6d2a82a72f48b0f (diff) | |
parent | ae940f950c2c62ae77561c913319ff25a46652e9 (diff) | |
download | numpy-246ad1dd3006ed4230a5c457838450f96df755e7.tar.gz |
Merge branch 'master' into doc-nditer
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 22 |
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): |