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

David M. Cooke cookedm at physics.mcmaster.ca
Tue Jun 6 13:46:29 CDT 2006


On Tue, 06 Jun 2006 20:20:21 +0200
massimo sandal <massimo.sandal at unibo.it> wrote:

> 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

You're using Numeric here, not numpy.

[snip error in scipy]
> In my .matplotlibrc the numerix backend is Numeric.
> I'm on Debian Sarge; MPL version is 0.82 ; Scipy is 0.3.2

Any errors in those versions aren't going to be fixed (they're too old;
scipy 0.3.2 depends on Numeric, not numpy, etc.).

You might be happier upgrading to numpy (you'll need a newer
matplotlib too). Since you're just doing linear least squares, you won't
need scipy.

Unfortunately, there aren't any Debian packages yet...


> 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.

Numeric uses typecode (as you found out); numpy uses dtype.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
http://arbutus.physics.mcmaster.ca/dmc/ |cookedm at physics.mcmaster.ca



More information about the SciPy-user mailing list