2014-02-13 49 views
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

感謝,

+0

使用Python Shell IDLE在調試菜單中執行此操作,打開堆棧查看器並查看'self.bounds_error'並將其發佈。已經有一個錯誤,scipy似乎沒有以正確的方式處理這個問題。 – User

+0

有沒有辦法讓照片附上問題?我想打印屏幕上的堆棧查看器並附在這裏。我似乎都迷失在所有這些信息中。它確實說「如果self.bounds_error和below_bounds.any()」然後它列出了很多項目/功能 – mikayla

+0

有一種方法。編輯並有一個圖像符號。 – User

回答

1

我們在這裏得到同樣的錯誤消息。我認爲這不一定需要成爲您的代碼的問題。

在我們的情況下,切換到SciPy version 0.15.0而不是0.13.x可以解決問題。

所以它看起來像當前版本的SciPy接受更廣泛的輸入值。

相關問題