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

Skip to content

Commit 9af32e6

Browse files
authored
Merge pull request matplotlib#11862 from QuLogic/slice-tuple
Fix NumPy FutureWarning for non-tuple indexing.
2 parents 4833c88 + 230ab94 commit 9af32e6

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lib/matplotlib/mlab.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,7 @@ def detrend_mean(x, axis=None):
280280
if axis is not None and axis+1 > x.ndim:
281281
raise ValueError('axis(=%s) out of bounds' % axis)
282282

283-
# short-circuit 0-D array.
284-
if not x.ndim:
285-
return np.array(0., dtype=x.dtype)
286-
287-
# short-circuit simple operations
288-
if axis == 0 or axis is None or x.ndim <= 1:
289-
return x - x.mean(axis)
290-
291-
ind = [slice(None)] * x.ndim
292-
ind[axis] = np.newaxis
293-
return x - x.mean(axis)[ind]
283+
return x - x.mean(axis, keepdims=True)
294284

295285

296286
def detrend_none(x, axis=None):

0 commit comments

Comments
 (0)