[Scipy-svn] r3482 - trunk/scipy/stats/models/robust

scipy-svn@scip... scipy-svn@scip...
Thu Nov 1 09:41:22 CDT 2007


Author: cookedm
Date: 2007-11-01 09:41:20 -0500 (Thu, 01 Nov 2007)
New Revision: 3482

Modified:
   trunk/scipy/stats/models/robust/scale.py
Log:
Fix error in scipy/stats/models/robust/scale.py by making unsqueeze return
a view of the correct shape.


Modified: trunk/scipy/stats/models/robust/scale.py
===================================================================
--- trunk/scipy/stats/models/robust/scale.py	2007-11-01 14:25:15 UTC (rev 3481)
+++ trunk/scipy/stats/models/robust/scale.py	2007-11-01 14:41:20 UTC (rev 3482)
@@ -11,7 +11,7 @@
     >>> m = mean(x, axis=1)
     >>> m.shape
     (3, 5)
-    >>> unsqueeze(m, 1, x.shape)
+    >>> m = unsqueeze(m, 1, x.shape)
     >>> m.shape
     (3, 1, 5)
     >>>
@@ -19,7 +19,7 @@
 
     newshape = list(oldshape)
     newshape[axis] = 1
-    data.shape = newshape
+    return data.reshape(newshape)
 
 
 def MAD(a, c=0.6745, axis=0):
@@ -32,7 +32,7 @@
 
     a = N.asarray(a, N.float64)
     d = median(a, axis=axis)
-    unsqueeze(d, axis, a.shape)
+    d = unsqueeze(d, axis, a.shape)
 
     return median(N.fabs(a - d) / c, axis=axis)
 
@@ -49,7 +49,7 @@
 
     tmp = 2 * norm.cdf(c) - 1
     gamma = tmp + c**2 * (1 - tmp) - 2 * c * norm.pdf(c)
-    del(tmp)
+    del tmp 
 
     niter = 30
 
@@ -76,8 +76,8 @@
         else:
             self.scale = scale
 
-        unsqueeze(self.scale, self.axis, self.a.shape)
-        unsqueeze(self.mu, self.axis, self.a.shape)
+        self.scale = unsqueeze(self.scale, self.axis, self.a.shape)
+        self.mu = unsqueeze(self.mu, self.axis, self.a.shape)
 
         for donothing in self:
             pass
@@ -97,7 +97,7 @@
             mu = N.sum(subset * a + (1 - Huber.c) * subset, axis=self.axis) / a.shape[self.axis]
         else:
             mu = self.mu
-        unsqueeze(mu, self.axis, self.a.shape)
+        self.axis = unsqueeze(mu, self.axis, self.a.shape)
 
         scale = N.sum(subset * (a - mu)**2, axis=self.axis) / (self.n * Huber.gamma - N.sum(1. - subset, axis=self.axis) * Huber.c**2)
 
@@ -111,7 +111,7 @@
             self.scale = scale
             self.mu = mu
 
-        unsqueeze(self.scale, self.axis, self.a.shape)
+        self.scale = unsqueeze(self.scale, self.axis, self.a.shape)
 
         if self.iter >= self.niter:
             raise StopIteration



More information about the Scipy-svn mailing list