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

Skip to content

Commit 14d4c67

Browse files
committed
Merged revisions 7790 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7790 | efiring | 2009-09-18 20:28:43 -1000 (Fri, 18 Sep 2009) | 2 lines Fix bug in mlab.demean, with axis = -1 ........ svn path=/trunk/matplotlib/; revision=7791
1 parent e4ab17d commit 14d4c67

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/matplotlib/mlab.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ def detrend(x, key=None):
177177
def demean(x, axis=0):
178178
"Return x minus its mean along the specified axis"
179179
x = np.asarray(x)
180-
if axis:
181-
ind = [slice(None)] * axis
182-
ind.append(np.newaxis)
183-
return x - x.mean(axis)[ind]
184-
return x - x.mean(axis)
180+
if axis == 0 or axis is None or x.ndim <= 1:
181+
return x - x.mean(axis)
182+
ind = [slice(None)] * x.ndim
183+
ind[axis] = np.newaxis
184+
return x - x.mean(axis)[ind]
185185

186186
def detrend_mean(x):
187187
"Return x minus the mean(x)"

0 commit comments

Comments
 (0)