[Scipy-svn] r3239 - branches/0.5.2.x/Lib/odr

scipy-svn@scip... scipy-svn@scip...
Tue Aug 14 17:09:30 CDT 2007


Author: jarrod.millman
Date: 2007-08-14 17:09:26 -0500 (Tue, 14 Aug 2007)
New Revision: 3239

Modified:
   branches/0.5.2.x/Lib/odr/__init__.py
   branches/0.5.2.x/Lib/odr/models.py
   branches/0.5.2.x/Lib/odr/odrpack.py
   branches/0.5.2.x/Lib/odr/setup.py
Log:
trying to synch odr with trunk since odr is broken in 0.5.2


Modified: branches/0.5.2.x/Lib/odr/__init__.py
===================================================================
--- branches/0.5.2.x/Lib/odr/__init__.py	2007-08-14 21:46:55 UTC (rev 3238)
+++ branches/0.5.2.x/Lib/odr/__init__.py	2007-08-14 22:09:26 UTC (rev 3239)
@@ -1,47 +1,9 @@
-""" Orthogonal Distance Regression
+#
+# odr - Orthogonal Distance Regression
+#
 
-Introduction
-============
+from info import __doc__
 
-Why Orthogonal Distance Regression (ODR)? Sometimes one has measurement errors
-in the explanatory variable, not just the response variable. Ordinary Least
-Squares (OLS) fitting procedures treat the data for explanatory variables as
-fixed. Furthermore, OLS procedures require that the response variable be an
-explicit function of the explanatory variables; sometimes making the equation
-explicit is unwieldy and introduces errors. ODR can handle both of these cases
-with ease and can even reduce to the OLS case if necessary.
-
-ODRPACK is a FORTRAN-77 library for performing ODR with possibly non-linear
-fitting functions. It uses a modified trust-region Levenberg-Marquardt-type
-algorithm to estimate the function parameters. The fitting functions are
-provided by Python functions operating on NumPy arrays. The required derivatives
-may be provided by Python functions as well or may be numerically estimated.
-ODRPACK can do explicit or implicit ODR fits or can do OLS. Input and output
-variables may be multi-dimensional. Weights can be provided to account for
-different variances of the observations (even covariances between dimensions of
-the variables).
-
-odr provides two interfaces: a single function and a set of high-level classes
-that wrap that function. Please refer to their docstrings for more information.
-While the docstring of the function, odr, does not have a full explanation of
-its arguments, the classes do, and the arguments with the same name usually have
-the same requirements. Furthermore, it is highly suggested that one at least
-skim the ODRPACK User's Guide.  Know Thy Algorithm.
-
-
-Use
-===
-
-See the docstrings of odr.odrpack and the functions and classes for
-usage instructions. The ODRPACK User's Guide is also quite helpful. It can be
-found on one of the ODRPACK's original author's website:
-
-    http://www.boulder.nist.gov/mcsd/Staff/JRogers/odrpack.html
-
-Robert Kern
-robert.kern@gmail.com
-"""
-
 __version__ = '0.7'
 __author__ = 'Robert Kern <robert.kern@gmail.com>'
 __date__ = '2006-09-21'
@@ -59,4 +21,6 @@
 __all__ = ['odr', 'odr_error', 'odr_stop', 'Data', 'RealData', 'Model',
            'Output', 'ODR', 'odrpack']
 
+from numpy.testing import NumpyTest
+test = NumpyTest().test
 #### EOF #######################################################################

Modified: branches/0.5.2.x/Lib/odr/models.py
===================================================================
--- branches/0.5.2.x/Lib/odr/models.py	2007-08-14 21:46:55 UTC (rev 3238)
+++ branches/0.5.2.x/Lib/odr/models.py	2007-08-14 22:09:26 UTC (rev 3239)
@@ -1,9 +1,8 @@
 """ Collection of Model instances for use with the odrpack fitting package.
 """
 
-# Scipy imports.
-from scipy.sandbox.odr.odrpack import Model
 import numpy as np
+from scipy.odr.odrpack import Model
 
 
 def _lin_fcn(B, x):

Modified: branches/0.5.2.x/Lib/odr/odrpack.py
===================================================================
--- branches/0.5.2.x/Lib/odr/odrpack.py	2007-08-14 21:46:55 UTC (rev 3238)
+++ branches/0.5.2.x/Lib/odr/odrpack.py	2007-08-14 22:09:26 UTC (rev 3239)
@@ -100,7 +100,7 @@
 """
 
 import numpy
-from scipy.sandbox.odr import __odrpack
+from scipy.odr import __odrpack
 
 odr = __odrpack.odr
 odr_error = __odrpack.odr_error
@@ -140,7 +140,7 @@
                   'Sum of squares convergence',
                   'Parameter convergence',
                   'Both sum of squares and parameter convergence',
-                  'Iteration limit reached')[info % 10]
+                  'Iteration limit reached')[info % 5]
 
     if info >= 5:
         # questionable results or fatal error
@@ -320,7 +320,7 @@
     covx and covy are arrays of covariance matrices and are converted to weights
     by performing a matrix inversion on each observation's covariance matrix.
 
-      E.g.  we[i] = scipy.linalg.inv(covy[i])  # i in range(len(covy))
+      E.g.  we[i] = numpy.linalg.inv(covy[i])  # i in range(len(covy))
                                                #   if covy.shape == (n,q,q)
 
     These arguments follow the same structured argument conventions as wd and we
@@ -376,15 +376,15 @@
         """ Convert covariance matrix(-ices) to weights.
         """
 
-        from scipy import linalg
+        from numpy.dual import inv
 
         if len(cov.shape) == 2:
-            return linalg.inv(cov)
+            return inv(cov)
         else:
             weights = numpy.zeros(cov.shape, float)
 
             for i in range(cov.shape[-1]):  # n
-                weights[:,:,i] = linalg.inv(cov[:,:,i])
+                weights[:,:,i] = inv(cov[:,:,i])
 
             return weights
 

Modified: branches/0.5.2.x/Lib/odr/setup.py
===================================================================
--- branches/0.5.2.x/Lib/odr/setup.py	2007-08-14 21:46:55 UTC (rev 3238)
+++ branches/0.5.2.x/Lib/odr/setup.py	2007-08-14 22:09:26 UTC (rev 3239)
@@ -1,18 +1,11 @@
 #!/usr/bin/env python
 
-import os,sys,re
-from distutils import dep_util
-from glob import glob
-import warnings
+from os.path import join
 
-from numpy.distutils.core import Extension
-from numpy.distutils.misc_util import get_path, Configuration, dot_join
-
-from numpy.distutils.system_info import get_info,dict_append,\
-     AtlasNotFoundError,LapackNotFoundError,BlasNotFoundError,\
-     LapackSrcNotFoundError,BlasSrcNotFoundError
-
 def configuration(parent_package='', top_path=None):
+    import warnings
+    from numpy.distutils.misc_util import Configuration
+    from numpy.distutils.system_info import get_info, BlasNotFoundError
     config = Configuration('odr', parent_package, top_path)
 
     libodr_files = ['d_odr.f',
@@ -26,7 +19,7 @@
         warnings.warn(BlasNotFoundError.__doc__)
         libodr_files.append('d_lpkbls.f')
 
-    libodr = [os.path.join('odrpack', x) for x in libodr_files]
+    libodr = [join('odrpack', x) for x in libodr_files]
     config.add_library('odrpack', sources=libodr)
     sources = ['__odrpack.c']
     libraries = ['odrpack'] + blas_info.pop('libraries', [])
@@ -38,6 +31,7 @@
         **blas_info
     )
 
+    config.add_data_dir('tests')
     return config
 
 if __name__ == '__main__':



More information about the Scipy-svn mailing list