1
我写了一个脚本做插值错误“布尔”对象有没有属性“任何”
import scipy.interpolate
import csv
inputfile1 = 'test.csv'
outputfile = 'Day1_out.csv'
distance_list = []
EC_list = []
new_dist_list=[]
outfile = open(outputfile,'w')
outfile.write('Distance,EC\n')
with open (inputfile1,'rb') as csvfile:
f1 = csv.reader(csvfile,delimiter=',')
next(f1) #skip header line
for row in f1:
dist = row[12]
EC=row[13]
distance_list.append(dist)
EC_list.append(EC)
y_interp = scipy.interpolate.interp1d(distance_list,EC_list)
new_dist = 561.7
end = 560.2
while new_dist>end:
new_dist_list.append(dist)
new_dist=new_dist-0.2
for distance in new_dist_list:
EC=y_interp(distance)
outfile.write(str(distance)+','+str(EC)+'\n')
outfile.close()
当我运行该脚本它给我的错误信息 回溯(最近通话最后一个):
File "D:\14046\Scripts\interpolation_RoR.py", line 41, in <module>
EC=y_interp(distance)
File "C:\Python27\lib\site-packages\scipy\interpolate\polyint.py", line 54, in __call__
y = self._evaluate(x)
File "C:\Python27\lib\site-packages\scipy\interpolate\interpolate.py", line 448, in _evaluate
out_of_bounds = self._check_bounds(x_new)
File "C:\Python27\lib\site-packages\scipy\interpolate\interpolate.py", line 474, in _check_bounds
if self.bounds_error and below_bounds.any():
AttributeError: 'bool' object has no attribute 'any'
任何人有任何想法,我有什么错误吗?
顺便说一句,该输入文件具有用于距离和EC
距离这些值,EC
561.8,450
561.78,446
561.7,444
561.2, 440
561.02,438
560.5,437
560.1,435
感谢,
使用Python Shell IDLE在调试菜单中执行此操作,打开堆栈查看器并查看'self.bounds_error'并将其发布。已经有一个错误,scipy似乎没有以正确的方式处理这个问题。 – User
有没有办法让照片附上问题?我想打印屏幕上的堆栈查看器并附在这里。我似乎都迷失在所有这些信息中。它确实说“如果self.bounds_error和below_bounds.any()”然后它列出了很多项目/功能 – mikayla
有一种方法。编辑并有一个图像符号。 – User