Python 2.7 错误';布尔';对象没有属性';任何';

Python 2.7 错误';布尔';对象没有属性';任何';,python-2.7,scipy,Python 2.7,Scipy,我写了一个脚本来做插值 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

我写了一个脚本来做插值

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()
当我运行脚本时,它给了我错误消息 回溯(最近一次呼叫最后一次):

文件“D:\14046\Scripts\interpolation_RoR.py”,第41行,在
EC=y_间隔(距离)
文件“C:\Python27\lib\site packages\scipy\interpolate\polyint.py”,第54行,在调用中__
y=自我评估(x)
文件“C:\Python27\lib\site packages\scipy\interpolate\interpolate.py”,第448行,在
超出界限=自我。检查界限(x新)
文件“C:\Python27\lib\site packages\scipy\interpolate\interpolate.py”,第474行,在检查范围内
如果self.bounds_错误且低于_bounds.any():
AttributeError:“bool”对象没有属性“any”
有人知道我哪里出错了吗

顺便说一句,输入文件中有这些距离和EC值

距离,EC

561.8450

561.78446

561.7444

561.2440

561.02438

560.5437

560.1435


谢谢,

我们在这里收到相同的错误消息。我认为这不一定是代码的问题

在我们的例子中,切换到
SciPy版本0.15.0
而不是
0.13.x
解决了这个问题


因此,当前版本的SciPy似乎接受更大范围的输入值。

在Python Shell空闲时执行此操作,在“调试”菜单中打开堆栈查看器,查看
self.bounds\u error
并发布它。已经有一个错误,scipy似乎没有以正确的方式处理这个问题。有没有一种方法可以将照片附加到问题中?我想打印堆栈查看器的屏幕并附加到这里。我似乎被这些信息迷住了。它确实会说“if self.bounds\u error and below\u bounds.any()”,然后它会列出许多项/函数。编辑并有一个图像符号。我需要至少10个声誉才能发布图像:(在self.bounds\u error和below\u bounds.any()\locals下,我有below\u bound=True、self=、below\u bounds=False和x\u new=array([561.7])。我猜错误在上下限,但在itI中找不到任何明显的错误消息。我发现我有一个错误。我忘记在插值之前将dist_列表和EC_列表中的项转换为float。我修复了它,但它仍然给我错误值error:x_new中的值低于插值范围
  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'