[Scipy-svn] r2547 - in trunk/Lib/sandbox/models: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Sun Jan 14 07:12:34 CST 2007


Author: jarrod.millman
Date: 2007-01-14 07:12:30 -0600 (Sun, 14 Jan 2007)
New Revision: 2547

Modified:
   trunk/Lib/sandbox/models/bspline.py
   trunk/Lib/sandbox/models/cox.py
   trunk/Lib/sandbox/models/gam.py
   trunk/Lib/sandbox/models/glm.py
   trunk/Lib/sandbox/models/setup.py
   trunk/Lib/sandbox/models/smoothers.py
   trunk/Lib/sandbox/models/tests/test_robust.py
Log:
minor clean ups


Modified: trunk/Lib/sandbox/models/bspline.py
===================================================================
--- trunk/Lib/sandbox/models/bspline.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/bspline.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -1,10 +1,9 @@
-
 import numpy as N
 import numpy.linalg as L
 
+from scipy.linalg import solveh_banded
 from scipy.optimize import golden
 from scipy.sandbox.models import _bspline
-from scipy.linalg import solveh_banded
 
 def _upper2lower(ub):
     """

Modified: trunk/Lib/sandbox/models/cox.py
===================================================================
--- trunk/Lib/sandbox/models/cox.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/cox.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -1,6 +1,8 @@
 import shutil
 import tempfile
+
 import numpy as N
+
 from scipy.sandbox.models import survival, model
 
 class discrete:
@@ -197,7 +199,7 @@
     for i in range(2*n):
         subjects[i].X = X[i]
 
-    import formula as F
+    import scipy.sandbox.models.formula as F
     x = F.quantitative('X')
     f = F.formula(x)
 

Modified: trunk/Lib/sandbox/models/gam.py
===================================================================
--- trunk/Lib/sandbox/models/gam.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/gam.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -1,9 +1,9 @@
 import numpy as N
+
 from scipy.sandbox.models import family
+from scipy.sandbox.models.bspline import SmoothingSpline
+from scipy.sandbox.models.glm import model as glm
 
-from glm import model as glm
-from bspline import SmoothingSpline
-
 def default_smoother(x):
     _x = x.copy()
     _x.sort()

Modified: trunk/Lib/sandbox/models/glm.py
===================================================================
--- trunk/Lib/sandbox/models/glm.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/glm.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -25,11 +25,13 @@
         """
         if results is None:
             results = self.results
-        if Y is None: Y = self.Y
+        if Y is None:
+            Y = self.Y
         return self.family.deviance(Y, results.mu) / scale
 
     def next(self):
-        results = self.results; Y = self.Y
+        results = self.results
+        Y = self.Y
         self.weights = self.family.weights(results.mu)
         self.initialize(self.design)
         Z = results.predict + self.family.link.deriv(results.mu) * (Y - results.mu)

Modified: trunk/Lib/sandbox/models/setup.py
===================================================================
--- trunk/Lib/sandbox/models/setup.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/setup.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -8,7 +8,7 @@
     config.add_data_dir('tests')
 
     try:
-        from bspline_module import mod
+        from scipy.sandbox.models.bspline_module import mod
         n, s, d = weave_ext(mod)
         config.add_extension(n, s, **d)
     except ImportError: pass

Modified: trunk/Lib/sandbox/models/smoothers.py
===================================================================
--- trunk/Lib/sandbox/models/smoothers.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/smoothers.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -7,13 +7,11 @@
 import numpy as N
 import numpy.linalg as L
 
-from scipy.optimize import golden
 from scipy.linalg import solveh_banded
+from scipy.optimize import golden
 
-from bspline import bspline
-from utils import band2array
-
 from scipy.sandbox.models import _bspline
+from scipy.sandbox.models.bspline import bspline, band2array
 
 
 class poly_smoother:
@@ -96,7 +94,7 @@
 
         mask = N.flatnonzero(1 - N.alltrue(N.equal(bt, 0), axis=0))
 
-        bt = bt[:,mask]
+        bt = bt[:, mask]
         y = y[mask]
 
         self.df_total = y.shape[0]
@@ -115,9 +113,9 @@
             nband, nbasis = self.g.shape
             for i in range(nbasis):
                 for k in range(min(nband, nbasis-i)):
-                    self.btb[k,i] = (bt[i] * bt[i+k]).sum()
+                    self.btb[k, i] = (bt[i] * bt[i+k]).sum()
 
-            bty.shape = (1,bty.shape[0])
+            bty.shape = (1, bty.shape[0])
             self.chol, self.coef = solveh_banded(self.btb + 
                                                  pen*self.g,
                                                  bty, lower=1)
@@ -164,7 +162,6 @@
             return self.rank
 
 class smoothing_spline_fixeddf(smoothing_spline):
-
     """
     Fit smoothing spline with approximately df degrees of freedom
     used in the fit, i.e. so that self.trace() is approximately df.
@@ -172,7 +169,6 @@
     In general, df must be greater than the dimension of the null space
     of the Gram inner product. For cubic smoothing splines, this means
     that df > 2.
-
     """
 
     target_df = 5

Modified: trunk/Lib/sandbox/models/tests/test_robust.py
===================================================================
--- trunk/Lib/sandbox/models/tests/test_robust.py	2007-01-14 12:35:28 UTC (rev 2546)
+++ trunk/Lib/sandbox/models/tests/test_robust.py	2007-01-14 13:12:30 UTC (rev 2547)
@@ -1,8 +1,9 @@
-import scipy.sandbox.models as S
 import unittest
+
 import numpy.random as R
-import numpy as N
 
+import scipy.sandbox.models as S
+
 W = R.standard_normal
 
 class RegressionTest(unittest.TestCase):



More information about the Scipy-svn mailing list