[SciPy-user] Pb with scipy.interpolate.spalde and numpy.float64
LB
berthe.loic at gmail.com
Sun Mar 16 10:24:36 EDT 2008
Hi,
scipy.interpolate.spalde accepts float as first argument but does not
work with numpy.float64 :
With python's float :
In [166]: c, type(c)
Out[166]: (0.52752752752752752, <type 'float'>)
In [167]: x, y = interpolate.spalde(c, tck)
=> no pb.
With numpy.float64 :
In [168]: b, type(b)
Out[168]: (0.52752752752752752, <type 'numpy.float64'>)
In [169]: x, y = interpolate.spalde(b, tck)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'> Traceback (most recent call
last)
/home/loic/Python/test_profil/<ipython console> in <module>()
/home/loic/tmp/bluelagoon/lib/python2.5/site-packages/scipy/
interpolate/fitpack.py in spalde(x, tck)
575 parametric = False
576 if parametric:
--> 577 return _ntlist(map(lambda c,x=x,t=t,k=k:spalde(x,
[t,c,k]),c))
578 else:
579 try: x=x.tolist()
/home/loic/tmp/bluelagoon/lib/python2.5/site-packages/scipy/
interpolate/fitpack.py in <lambda>(c, x, t, k)
575 parametric = False
576 if parametric:
--> 577 return _ntlist(map(lambda c,x=x,t=t,k=k:spalde(x,
[t,c,k]),c))
578 else:
579 try: x=x.tolist()
/home/loic/tmp/bluelagoon/lib/python2.5/site-packages/scipy/
interpolate/fitpack.py in spalde(x, tck)
581 try: x=list(x)
582 except: x=[x]
--> 583 if len(x)>1:
584 return map(lambda x,tck=tck:spalde(x,tck),x)
585 d,ier=_fitpack._spalde(t,c,k,x[0])
<type 'exceptions.TypeError'>: object of type 'float' has no len()
It seems to come from the method 'tolist' of numpy.float64, which does
not return a list :
In [174]: c.tolist()
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'> Traceback (most recent call
last)
/home/loic/Python/test_profil/<ipython console> in <module>()
<type 'exceptions.AttributeError'>: 'float' object has no attribute
'tolist'
In [175]: b.tolist()
Out[175]: 0.52752752752752752
So my question is : why do numpy.float64 have a tolist method, and why
does it not return a list ?
for information,
In [179]: numpy.__version__, scipy.__version__
Out[179]: ('1.0.5.dev4854', '0.7.0.dev4004')
--
LB
More information about the SciPy-User
mailing list