[Scipy-svn] r4625 - branches/stats_models

scipy-svn at scipy.org scipy-svn at scipy.org
Fri Aug 8 15:52:21 EDT 2008


Author: chris.burns
Date: 2008-08-08 14:52:18 -0500 (Fri, 08 Aug 2008)
New Revision: 4625

Modified:
   branches/stats_models/bspline.py
Log:
Undo rename of bspline.py, which would have created test failures for anyone without a clean install.

Modified: branches/stats_models/bspline.py
===================================================================
--- branches/stats_models/bspline.py	2008-08-08 19:33:35 UTC (rev 4624)
+++ branches/stats_models/bspline.py	2008-08-08 19:52:18 UTC (rev 4625)
@@ -20,8 +20,16 @@
 
 from scipy.linalg import solveh_banded
 from scipy.optimize import golden
-from scipy.stats.models import _bspline
+from scipy.stats.models import _hbspline
 
+
+# Issue warning regarding heavy development status of this module
+import warnings
+_msg = "The bspline code is technology preview and requires significant work\
+on the public API and documentation. The API will likely change in the future"
+warnings.warn(_msg, UserWarning)
+
+
 def _band2array(a, lower=0, symmetric=False, hermitian=False):
     """
     Take an upper or lower triangular banded matrix and return a
@@ -190,6 +198,10 @@
                  Bspline to avoid extra evaluation in the __call__ method
 
     '''
+    # FIXME: update parameter names, replace single character names 
+    # FIXME: `order` should be actual spline order (implemented as order+1)
+    ## FIXME: update the use of spline order in extension code (evaluate is recursively called) 
+    # FIXME: eliminate duplicate M and m attributes (m is order, M is related to tau size)
 
     def __init__(self, knots, order=4, M=None, coef=None, x=None):
 
@@ -277,7 +289,7 @@
         x.shape = (N.product(_shape,axis=0),)
         if i < self.tau.shape[0] - 1:
            ## TODO: OWNDATA flags...
-            v = _bspline.evaluate(x, self.tau, self.m, d, i, i+1)
+            v = _hbspline.evaluate(x, self.tau, self.m, d, i, i+1)
         else:
             return N.zeros(x.shape, N.float64)
 
@@ -321,7 +333,7 @@
 
         d = N.asarray(d)
         if d.shape == ():
-            v = _bspline.evaluate(x, self.tau, self.m, int(d), lower, upper)
+            v = _hbspline.evaluate(x, self.tau, self.m, int(d), lower, upper)
         else:
             if d.shape[0] != 2:
                 raise ValueError, "if d is not an integer, expecting a jx2 \
@@ -330,7 +342,7 @@
 
             v = 0
             for i in range(d.shape[1]):
-                v += d[1,i] * _bspline.evaluate(x, self.tau, self.m, d[0,i], lower, upper)
+                v += d[1,i] * _hbspline.evaluate(x, self.tau, self.m, d[0,i], lower, upper)
 
         v.shape = (upper-lower,) + _shape
         if upper == self.tau.shape[0] - self.m:
@@ -373,7 +385,7 @@
 
         d = N.squeeze(d)
         if N.asarray(d).shape == ():
-            self.g = _bspline.gram(self.tau, self.m, int(d), int(d))
+            self.g = _hbspline.gram(self.tau, self.m, int(d), int(d))
         else:
             d = N.asarray(d)
             if d.shape[0] != 2:
@@ -385,7 +397,7 @@
             self.g = 0
             for i in range(d.shape[1]):
                 for j in range(d.shape[1]):
-                    self.g += d[1,i]* d[1,j] * _bspline.gram(self.tau, self.m, int(d[0,i]), int(d[0,j]))
+                    self.g += d[1,i]* d[1,j] * _hbspline.gram(self.tau, self.m, int(d[0,i]), int(d[0,j]))
         self.g = self.g.T
         self.d = d
         return N.nan_to_num(self.g)
@@ -425,6 +437,8 @@
 
            fhat = ARGMIN_f SUM_i=1^n (y_i-f(x_i))^2 + pen * int f^(2)^2
 
+	   int is integral. pen is lambda (from Hastie)
+
            See Chapter 5 of
 
            Hastie, Tibshirani and Friedman (2001). "The Elements of Statistical
@@ -553,7 +567,7 @@
         """
 
         if self.pen > 0:
-            _invband = _bspline.invband(self.chol.copy())
+            _invband = _hbspline.invband(self.chol.copy())
             tr = _trace_symbanded(_invband, self.btb, lower=1)
             return tr
         else:




More information about the Scipy-svn mailing list