diff options
author | Jonathan Helmus <jjhelmus@gmail.com> | 2013-09-16 10:32:25 -0600 |
---|---|---|
committer | Jonathan Helmus <jjhelmus@gmail.com> | 2013-09-16 10:32:25 -0600 |
commit | 9dd212cee1c9ccab6013d52e776bcf6ef712a5e0 (patch) | |
tree | a4a4414bd29efdf3d023fbba9a5d5690063fd579 /numpy/lib | |
parent | 9aed31a8ba1607241947bfe886821e9eb09f6ebb (diff) | |
download | numpy-9dd212cee1c9ccab6013d52e776bcf6ef712a5e0.tar.gz |
MAINT: changed 'closest' interpolation to 'nearest'
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/function_base.py | 8 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 1f6484959..9475c2edf 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2780,14 +2780,14 @@ def percentile(a, q, interpolation='linear', axis=None, out=None, Input array or object that can be converted to an array. q : float in range of [0,100] (or sequence of floats) Percentile to compute which must be between 0 and 100 inclusive. - interpolation : {'linear', 'lower', 'higher', 'midpoint', 'closest'} + interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'} This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points `i` and `j`: * linear: `i + (j - i) * fraction`, where `fraction` is the fractional part of the index surrounded by `i` and `j`. * lower: `i`. * higher: `j`. - * closest: `i` or `j` whichever is closest. + * nearest: `i` or `j` whichever is nearest. * midpoint: (`i` + `j`) / 2. axis : int, optional Axis along which the percentiles are computed. The default (None) @@ -2890,13 +2890,13 @@ def percentile(a, q, interpolation='linear', axis=None, out=None, indices = ceil(indices).astype(intp) elif interpolation == 'midpoint': indices = floor(indices) + 0.5 - elif interpolation == 'closest': + elif interpolation == 'nearest': indices = around(indices).astype(intp) elif interpolation == 'linear': pass # keep index as fraction and interpolate else: raise ValueError("interpolation can only be 'linear', 'lower' " - "'higher', 'midpoint', or 'closest'") + "'higher', 'midpoint', or 'nearest'") if indices.dtype == intp: # take the points along axis ap.partition(indices, axis=axis) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 6923f0004..a69c82e18 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1477,11 +1477,11 @@ class TestScoreatpercentile(TestCase): assert_equal(np.percentile(range(10), 51, interpolation='midpoint'), 4.5) - def test_closest(self): + def test_nearest(self): assert_equal(np.percentile(range(10), 51, - interpolation='closest'), 5) + interpolation='nearest'), 5) assert_equal(np.percentile(range(10), 49, - interpolation='closest'), 4) + interpolation='nearest'), 4) def test_sequence(self): x = np.arange(8) * 0.5 |