我最近遇到了类似的错误:
IndexError Traceback (most recent call last)
<ipython-input-124-59ca523b1b36> in <module>()
----> 1 first_experiment_comb(model)
c:\python26\26664\lib\site-packages\experiments.py in first_experiment_comb(mod
l)
172 "Number NZ: " + str(modelz[j].NumNZs) +"\n")
173
--> 174 first_experiment(modelz[j], str(j))
175
176
c:\python26\26664\lib\site-packages\experiments.py in first_experiment(model, e
t)
89 plt.close()
90
---> 91 fl.timberFlow(model)
92 plt.savefig(dire + "\\timber_flow" +ext+".pdf", bbox_inches = 0)
93 plt.close()
C:\Python26\26664\lib\site-packages\func_lib.py in timberFlow(model)
304 if not unVars:
305 unVars = varValues(model, 'PIEHTLVOL')
--> 306
307 for i in range(19):
308 swVarVals.append(swVars[i].X)
IndexError: list index out of range
跟踪的最后一行指向不存在的代码,或者在以前的情况下已被注释掉。当我自己运行最后一个函数(在func_lib.py中)时,我永远不会得到神秘的IndexError,只有当它从experiments.py调用时。
我在 pylab python 2.6 W64 中运行它。我无法在 iPython 或 Pylab 文档中找到关于此的已知错误。
第 306 行怎么可能是错误的根源?