[SciPy-user] numpy.asarray and Numeric.asarray

Steve Schmerler elcorto at gmx.net
Tue Jan 24 04:29:51 CST 2006


Using optimize.fmin_powell from a recent svn build with the initial 
guess x0 being a scalar I get this error:

Traceback (most recent call last):
   File "trans.py", line 151, in ?
     tau = fmin_powell(func, tau_start)
   File "/usr/lib/python2.3/site-packages/scipy/optimize/optimize.py", 
line 1453, in fmin_powell
     N = len(x)
TypeError: len() of unsized object

where x = asarray(x0). Comparing numpy's and Numeric's asarray I found

In [8]: import numpy as nu

In [9]: import Numeric as NU

In [10]: x = nu.asarray([1,2]); len(x)
Out[10]: 2

In [11]: y = NU.asarray([1,2]); len(y)
Out[11]: 2

In [12]: x = nu.asarray(3); len(x)
exceptions.TypeError                                 Traceback (most 
recent call last)


TypeError: len() of unsized object

In [13]: y = NU.asarray(3); len(y)
Out[13]: 1



"People like Blood Sausage too. People are Morons!" -- Phil Connors, 
Groundhog Day

More information about the SciPy-user mailing list