提交 9769b065 authored 作者: Josh Bleecher Snyder's avatar Josh Bleecher Snyder

Fix error message when args contains an ndarray.

numpy.ndarray overrides __eq__ to do elemwise equality checks, thus yielding an ndarray, which cannot be cast as a bool. This doesn't play nicely with list.index; numpy throws a ValueError.
......@@ -510,7 +510,7 @@ class Function(object):
# Set positional arguments
i = 0
for arg in args:
for arg_index, arg in enumerate(args):
#TODO: provide a Param option for skipping the filter if we
# really want speed.
s = self.input_storage[i]
......@@ -520,7 +520,7 @@ class Function(object):
try:
s.storage[0] = s.type.filter(arg, strict=s.strict)
except Exception, e:
e.args = tuple(list(e.args)+["Bad input argument at index %d"%(list(args).index(arg))])
e.args = tuple(list(e.args)+["Bad input argument at index %d" % arg_index])
raise
s.provided += 1
i+=1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论