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

Skip to content

Commit 230ab94

Browse files
committed
Fix NumPy FutureWarning for non-tuple indexing.
This fixes the warning: .../matplotlib/mlab.py:395: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
1 parent 8a8c881 commit 230ab94

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
@@ -382,17 +382,7 @@ def detrend_mean(x, axis=None):
382382
if axis is not None and axis+1 > x.ndim:
383383
raise ValueError('axis(=%s) out of bounds' % axis)
384384

385-
# short-circuit 0-D array.
386-
if not x.ndim:
387-
return np.array(0., dtype=x.dtype)
388-
389-
# short-circuit simple operations
390-
if axis == 0 or axis is None or x.ndim <= 1:
391-
return x - x.mean(axis)
392-
393-
ind = [slice(None)] * x.ndim
394-
ind[axis] = np.newaxis
395-
return x - x.mean(axis)[ind]
385+
return x - x.mean(axis, keepdims=True)
396386

397387

398388
def detrend_none(x, axis=None):

0 commit comments

Comments
 (0)