summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorJoseph Fox-Rabinovitz <joseph.r.fox-rabinovitz@nasa.gov>2016-01-27 10:21:46 -0500
committerJoseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com>2016-01-31 20:04:01 -0500
commit9ec694b69a231a8de43032711c657d253edbed9d (patch)
tree2b36d09515f869165a17bdb41996ed4b98c0b261 /numpy/lib/tests/test_function_base.py
parentcc2b0495118e4855acfeaea3253abf449f3e91dd (diff)
downloadnumpy-9ec694b69a231a8de43032711c657d253edbed9d.tar.gz
BUG: Fixed 'midpoint' interpolation of np.percentile in odd cases.
'midpoint' must return the same as 'higher' and 'lower' when the two are the same, not 'lower' + 0.5 as it was doing.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index d6a838f3a..56466c1ea 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2055,7 +2055,7 @@ def compare_results(res, desired):
assert_array_equal(res[i], desired[i])
-class TestScoreatpercentile(TestCase):
+class TestPercentile(TestCase):
def test_basic(self):
x = np.arange(8) * 0.5
@@ -2104,6 +2104,10 @@ class TestScoreatpercentile(TestCase):
def test_midpoint(self):
assert_equal(np.percentile(range(10), 51,
interpolation='midpoint'), 4.5)
+ assert_equal(np.percentile(range(11), 51,
+ interpolation='midpoint'), 5.5)
+ assert_equal(np.percentile(range(11), 50,
+ interpolation='midpoint'), 5)
def test_nearest(self):
assert_equal(np.percentile(range(10), 51,