提交 46e72e92 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Fix to rebroadcast's __str__ when no axis is provided

上级 eb506b5b
......@@ -2581,7 +2581,10 @@ class Rebroadcast(Op):
items.sort() #no ambiguity because each item key is unique
return hash(type(self)) ^ hash(tuple(items))
def __str__(self):
broadcast_pattern = ['?' for i in range(1+numpy.max(self.axis.keys()))]
if len(self.axis) == 0:
broadcast_pattern = []
else:
broadcast_pattern = ['?' for i in range(1+numpy.max(self.axis.keys()))]
for k,v in self.axis.iteritems():
broadcast_pattern[k] = str(int(v))
return '%s{%s}' % (self.__class__.__name__, ','.join(broadcast_pattern))
......
......@@ -65,7 +65,8 @@ def merge_broadcastables(broadcastables):
def get_constant_value(v):
"""return the constant scalar(0-D) value underlying variable `v`
If v is the output of dimshuffles, fills, allocs, this function digs through them.
If v is the output of dimshuffles, fills, allocs, rebroadcasts,
this function digs through them.
If `v` is not some view of constant data, then raise a TypeError.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论