[SciPy-user] optimize.leastsq crashs my interpreter

Nils Wagner nwagner at iam.uni-stuttgart.de
Fri Jul 7 06:50:36 EDT 2006


Hans Georg Krauthäuser wrote:
> Hi all,
>
> I've tried to use optimize.leastsq from a fresh binary install of numpy 
> and scipy with python 2.4 on XP. A call to optimize.leastsq results in 
> the crash of the interpreter without any traceback. XP tells me that the 
> problem occurs inside _minpack.pyd.
>
> I can reproduce the error with the following script on two different 
> computers
> -------------------8<------------------------
> import scipy
> scipy.pkgload('optimize')
>
> x=scipy.array([1., 2., 3.])
> y=scipy.array([4., 5., 6.])
>
> def res(p, y, x):
>      err=y-peval(x,p)
>      print p, y, x, err
>      return err
>
> def peval(x,p):
>      return p[0]*x+p[1]
>
> m_0=0.1
> b_0=0.0
>
> p0=scipy.array([m_0,b_0])
> plsq=scipy.optimize.leastsq(res, p0, args=(y,x))
>
> print plsq
> --------------------->8---------------------------
>
> If I comment out line 2 (pkgload) the script runs perfectly on an old 
> python installation (2.3) with old scipy and numpy.
>
> It would be nice if someone could try to reproduce the error.
>
> Please tell me also if something is wrong with my script.
>
> Regards
> Hans Georg
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>   


Your script works fine. I am on Linux.

[ 0.1  0. ] [ 4.  5.  6.] [ 1.  2.  3.] [ 3.9  4.8  5.7]
[ 0.1  0. ] [ 4.  5.  6.] [ 1.  2.  3.] [ 3.9  4.8  5.7]
[ 0.1  0. ] [ 4.  5.  6.] [ 1.  2.  3.] [ 3.9  4.8  5.7]
[ 0.1  0. ] [ 4.  5.  6.] [ 1.  2.  3.] [ 3.9  4.8  5.7]
[  1.00000000e-01   1.49011612e-08] [ 4.  5.  6.] [ 1.  2.  3.] [ 
3.89999999  4.79999999  5.69999999]
[ 0.99999992  3.00000018] [ 4.  5.  6.] [ 1.  2.  3.] [ -9.83561659e-08  
-1.78918595e-08   6.25724468e-08]
[ 0.99999993  3.00000018] [ 4.  5.  6.] [ 1.  2.  3.] [ -1.13257325e-07  
-4.76941793e-08   1.78689668e-08]
[ 0.99999992  3.00000022] [ 4.  5.  6.] [ 1.  2.  3.] [ -1.43059652e-07  
-6.25953458e-08   1.78689596e-08]
[ 1.  3.] [ 4.  5.  6.] [ 1.  2.  3.] [ -1.77635684e-15  
-1.77635684e-15  -2.66453526e-15]
[ 1.00000001  3.        ] [ 4.  5.  6.] [ 1.  2.  3.] [ -1.49011630e-08  
-2.98023242e-08  -4.47034862e-08]
[ 1.          3.00000004] [ 4.  5.  6.] [ 1.  2.  3.] [ -4.47034854e-08  
-4.47034854e-08  -4.47034862e-08]
[ 1.  3.] [ 4.  5.  6.] [ 1.  2.  3.] [ 0.  0.  0.]
(array([ 1.,  3.]), 2)
 >>> scipy.__version__
'0.5.0.2051'

Nils




More information about the SciPy-User mailing list