提交 1856586e authored 作者: Frederic's avatar Frederic

Try to fix duplicate key by making sure the hash is valid

上级 871f3879
......@@ -613,6 +613,9 @@ class Rebroadcast(gof.Op):
for axis, broad in iteritems(self.axis):
assert isinstance(axis, (numpy.integer, int)), (
"Rebroadcast needs integer axes. Got ", axis)
assert isinstance(broad, bool), (
"Rebroadcast needs bool for new broadcast pattern. Got ",
broad)
def __str__(self):
if len(self.axis) == 0:
......
......@@ -471,9 +471,7 @@ def hash_from_dict(d):
"""Work around the fact that dict are not hashable in python
This request that all object have a sorted order that depend only
on the value of the object. This is true for integer/float/string
We do not verify that the objects in the dict have this property.
on the key of the object. We support only integer/float/string keys.
Also, we transform values that are list into tuple as list are not
hashable.
......@@ -490,6 +488,7 @@ def hash_from_dict(d):
first_part = [k for k, v in items]
second_part = []
for k, v in items:
assert isinstance(k, (str, int, float))
if isinstance(v, (tuple, list)):
second_part += [tuple(v)]
else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论