[SciPy-user] linear_least_squares: OverFlow error or flapack.error

David Huard david.huard at gmail.com
Tue Jun 6 14:32:49 EDT 2006


For dytpe, try Float instead of float.

David



2006/6/6, massimo sandal <massimo.sandal at unibo.it>:
>
> Hi,
>
> I'm trying to do a simple linear least squares fit of some data in an
> application.
>
> The relevant code runs about as follows, following closely the example
> found on
> http://mail.python.org/pipermail/python-list/2006-March/331693.html
>
> ---------
> import matplotlib.numerix as nx
>
> contact_x_points=nx.array(x_points[left_bound:right_bound])
> contact_y_points=nx.array(y_points[left_bound:right_bound])
>
> A=nx.ones((len(contact_x_points),2))
> A[:,0]=contact_x_points
> result=nx.linear_algebra.linear_least_squares(A,contact_y_points)
> ---------
>
> ...but when I run, it crashes with:
>
> File "hooke.py", line 202, in find_contact_point
>      result=nx.linear_algebra.linear_least_squares(A,contact_y_points)
>    File "/usr/lib/python2.3/site-packages/Numeric/LinearAlgebra.py",
> line 416, in linear_least_squares
>      nlvl = max( 0, int( math.log( float(min( m,n ))/2. ) ) + 1 )
> OverflowError: math range error
>
>
> I also tried using scipy:
> -----------
> import scipy as sp
>
> contact_x_points=sp.array(x_points[left_bound:right_bound])
> contact_y_points=sp.array(y_points[left_bound:right_bound])
>
> A=sp.ones((len(contact_x_points),2))
> A[:,0]=contact_x_points           result=sp.linalg.lstsq
> (A,contact_y_points)
> -------------
>
> ... with another error:
>
> array_from_pyobj:intent(hide) must have defined dimensions.
> rank=1 dimensions=[ 0 ]
> Traceback:
> [...]
> File "hooke.py", line 202, in find_contact_point
>      result=sp.linalg.lstsq(A, contact_y_points)
>    File "/usr/lib/python2.3/site-packages/scipy/linalg/basic.py", line
> 344, in lstsq
>      overwrite_b = overwrite_b)
> flapack.error: failed in converting hidden `s' of flapack.dgelss to
> C/Fortran array
>
> In my .matplotlibrc the numerix backend is Numeric.
> I'm on Debian Sarge; MPL version is 0.82 ; Scipy is 0.3.2
>
>
> It must be noticed that I fail to declare
>
> A=nx.ones((len.contact_x_points),2),dtype=float)
> as the example should seem to require, because it gives me another error:
>
> TypeError: ones() got an unexpected keyword argument 'dtype'
>
> ...so if this is the problem, please tell me how to correctly pass the
> dtype argument.
>
> Since I'm quite a scipy/numeric newbie I guess there could be some
> obvious blunder and/or more correct way of obtaining my fit, and I'd be
> thankful to anyone pointing me at the solution...
>
> Thanks,
> Massimo
>
> --
> Massimo Sandal
> University of Bologna
> Department of Biochemistry "G.Moruzzi"
>
> snail mail:
> Via Irnerio 48, 40126 Bologna, Italy
>
> email:
> massimo.sandal at unibo.it
>
> tel: +39-051-2094388
> fax: +39-051-2094387
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060606/ec4b2368/attachment.html>


More information about the SciPy-User mailing list