2013-04-23 159 views
0

我在蟒蛇新鲜,使用python2.7,并得到了在代码中的一些问题,自爆:“模块”对象有没有属性“interpld”

import numpy as np 
from scipy import interpolate 
import pylab as py 

x=np.r_[0:10:11j] 
y=np.sin(x) 
xnew=np.r_[0:10:100j] 

#f=interpolate.interpld(x,y) 


py.figure(1) 
py.clf() 
py.plot(x,y,'ro') 
for kind in ['nearest','zero','slinear','quadtatic','cublic']: 
    f=interpolate.interpld(x,y,kind=kind) 
    ynew=f(xnew) 
    py.plot(xnew,ynew,label=kind) 
py.legend(loc='lower right') 

,但它造成了:

Traceback (most recent call last): 
    File "C:\Users\LCL\.xy\startups\python_web\my_first_try_on_python_web\python_Interpolation\example1.py", line 22, in <module> 
    f=interpolate.interpld(x,y,kind=kind) 
AttributeError: 'module' object has no attribute 'interpld' 
+0

什么'print scipy.interpolate .__ file__'说? – 2013-04-23 16:04:41

+0

它说:C:\ Python27 \ lib \ site-packages \ scipy \ interpolate \ __ init __。pyc – ray 2013-04-23 16:12:39

+0

至少你没有混淆模块。但正如下面的答案指出的那样,你拼错了一些东西。 – 2013-04-23 16:15:49

回答

2

您使用的是interpld,即INTERPLD

对于一维,您想要interp1d,即用数字1

+0

我刚刚解决了这个问题,但是还有另一个问题:Traceback(最近一次调用最后一个): 文件“C:\ Users \ LCL \ .xy \ startups \ python_web \ my_first_try_on_python_web \ python_Interpolation \ example1.py” f = interpolate.interp1d(x,y,kind = kind) “C:\ Python27 \ lib \ site-packages \ scipy \ interpolate \ interpolate.py”,行272,在__init__中 “其他例程类型“。 %kind) NotImplementedError:quadtatic不受支持:对其他类型使用fitpack例程。 – ray 2013-04-23 16:08:09

+2

同样,你可能是指“二次方”,而不是“四元”。 – DSM 2013-04-23 16:08:52

+1

..''cublic'应该是'立方体'。您可以在文档中看到允许的值列表('help(interpolate.interp1d)')。 – DSM 2013-04-23 16:13:07

1

它看起来像你使用interpolate.interpld但功能名称是interpolate.interp1d(与第一个而不是字母L)。

+0

我刚刚解决了它,但是这里又来了另一个问题:Traceback(最近调用最后一个): 文件“C:\ Users \ LCL \ .xy \ startups \ python_web \ my_first_try_on_python_web \ python_Interpolation \ example1.py“,第22行,在 f = interpolate.interp1d(x,y,kind = kind) 文件”C:\ Python27 \ lib \ site -packages \ scipy \ interpolate \ interpolate.py“,行272,在__init__ ”其他类型的例程“。 %kind) NotImplementedError:quadtatic不受支持:对其他类型使用fitpack例程。 – ray 2013-04-23 16:08:47

+1

@ray:你的意思是“二次的”而不是“四元的”? – BrenBarn 2013-04-23 16:09:22

+0

哦,我从youtube视频中学习,多么无心的人,谢谢你的指示 – ray 2013-04-23 16:21:26

相关问题