Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f69a814

Browse files
committed
Remove mlab.prctile and mlab.prctile_rank
1 parent d3251be commit f69a814

File tree

4 files changed

+3
-93
lines changed

4 files changed

+3
-93
lines changed

doc/api/next_api_changes/2018-09-18-DS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ in Matplotlib 2.2 has been removed. See below for a list:
1212
- `mlab.longest_contiguous_ones`
1313
- `mlab.longest_ones`
1414
- `mlab.PCA`
15+
- `mlab.prctile` (use numpy.percentile instead)
16+
- `mlab.prctile_rank`
1517
- `mlab.donothing_callback`

lib/matplotlib/mlab.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,72 +1194,6 @@ def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning,
11941194
return Cxy, f
11951195

11961196

1197-
@cbook.deprecated('2.2', 'numpy.percentile')
1198-
def prctile(x, p=(0.0, 25.0, 50.0, 75.0, 100.0)):
1199-
"""
1200-
Return the percentiles of *x*. *p* can either be a sequence of
1201-
percentile values or a scalar. If *p* is a sequence, the ith
1202-
element of the return sequence is the *p*(i)-th percentile of *x*.
1203-
If *p* is a scalar, the largest value of *x* less than or equal to
1204-
the *p* percentage point in the sequence is returned.
1205-
"""
1206-
1207-
# This implementation derived from scipy.stats.scoreatpercentile
1208-
def _interpolate(a, b, fraction):
1209-
"""Returns the point at the given fraction between a and b, where
1210-
'fraction' must be between 0 and 1.
1211-
"""
1212-
return a + (b - a) * fraction
1213-
1214-
per = np.array(p)
1215-
values = np.sort(x, axis=None)
1216-
1217-
idxs = per / 100 * (values.shape[0] - 1)
1218-
ai = idxs.astype(int)
1219-
bi = ai + 1
1220-
frac = idxs % 1
1221-
1222-
# handle cases where attempting to interpolate past last index
1223-
cond = bi >= len(values)
1224-
if per.ndim:
1225-
ai[cond] -= 1
1226-
bi[cond] -= 1
1227-
frac[cond] += 1
1228-
else:
1229-
if cond:
1230-
ai -= 1
1231-
bi -= 1
1232-
frac += 1
1233-
1234-
return _interpolate(values[ai], values[bi], frac)
1235-
1236-
1237-
@cbook.deprecated('2.2')
1238-
def prctile_rank(x, p):
1239-
"""
1240-
Return the rank for each element in *x*, return the rank
1241-
0..len(*p*). e.g., if *p* = (25, 50, 75), the return value will be a
1242-
len(*x*) array with values in [0,1,2,3] where 0 indicates the
1243-
value is less than the 25th percentile, 1 indicates the value is
1244-
>= the 25th and < 50th percentile, ... and 3 indicates the value
1245-
is above the 75th percentile cutoff.
1246-
1247-
*p* is either an array of percentiles in [0..100] or a scalar which
1248-
indicates how many quantiles of data you want ranked.
1249-
"""
1250-
1251-
if not np.iterable(p):
1252-
p = np.arange(100.0/p, 100.0, 100.0/p)
1253-
else:
1254-
p = np.asarray(p)
1255-
1256-
if p.max() <= 1 or p.min() < 0 or p.max() > 100:
1257-
raise ValueError('percentiles should be in range 0..100, not 0..1')
1258-
1259-
ptiles = prctile(x, p)
1260-
return np.searchsorted(ptiles, x)
1261-
1262-
12631197
@cbook.deprecated('2.2')
12641198
def center_matrix(M, dim=0):
12651199
"""

lib/matplotlib/pylab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
fftsurr, frange, get_sparse_matrix, get_xyz_where, griddata,
237237
identity, inside_poly, is_closed_polygon, ispower2, isvector, l1norm,
238238
l2norm, log2, movavg, norm_flat,
239-
path_length, poly_below, poly_between, prctile, prctile_rank,
239+
path_length, poly_below, poly_between,
240240
rec2csv, rec_append_fields, rec_drop_fields, rec_join, rk4, rms_flat,
241241
segments_intersect, slopes, stineman_interp, vector_lengths,
242242
window_hanning, window_none)

lib/matplotlib/tests/test_mlab.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,6 @@
2020
'''
2121

2222

23-
@pytest.mark.parametrize('input', [
24-
# test odd lengths
25-
[1, 2, 3],
26-
# test even lengths
27-
[1, 2, 3, 4],
28-
# derived from email sent by jason-sage to MPL-user on 20090914
29-
[1, 1, 2, 2, 1, 2, 4, 3, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 7, 6, 4, 5, 5],
30-
],
31-
ids=[
32-
'odd length',
33-
'even length',
34-
'custom data',
35-
])
36-
@pytest.mark.parametrize('percentile', [
37-
0,
38-
50,
39-
75,
40-
100,
41-
[0, 75, 100],
42-
])
43-
def test_prctile(input, percentile):
44-
with pytest.warns(MatplotlibDeprecationWarning):
45-
assert_allclose(mlab.prctile(input, percentile),
46-
np.percentile(input, percentile))
47-
48-
4923
class TestStride(object):
5024
def get_base(self, x):
5125
y = x

0 commit comments

Comments
 (0)