提交 641c47b8 authored 作者: James Bergstra's avatar James Bergstra

merge

...@@ -279,7 +279,7 @@ class T_function(unittest.TestCase): ...@@ -279,7 +279,7 @@ class T_function(unittest.TestCase):
a = T.dmatrix() a = T.dmatrix()
f = function([a], Out(a, borrow=False)) f = function([a], Out(a, borrow=False))
o = N.ones((3,3)) o = N.ones((3,3))
assert o is not f(o) assert o is f(o) #borrow does not imply copy.
class T_picklefunction(unittest.TestCase): class T_picklefunction(unittest.TestCase):
......
...@@ -1627,19 +1627,20 @@ class Subtensor(Op): ...@@ -1627,19 +1627,20 @@ class Subtensor(Op):
# for entry in self.idx_list) # for entry in self.idx_list)
return hash(idx_list) return hash(idx_list)
@staticmethod
def str_from_slice(entry):
msg = []
for x in [entry.start, entry.stop, entry.step]:
if x is None:
msg.append("")
else:
msg.append(str(x))
return ":".join(msg)
def __str__(self): def __str__(self):
indices = [] indices = []
for entry in self.idx_list: for entry in self.idx_list:
if isinstance(entry, slice): if isinstance(entry, slice):
msg = [] indices.append(self.str_from_slice(entry))
for x in [entry.start, entry.stop, entry.step]:
if x is None:
msg += ""
else:
msg += [str(x)]
indices.append(":".join(msg))
#backport
#indices.append(":".join("" if x is None else str(x) for x in [entry.start, entry.stop, entry.step]))
else: else:
indices.append(str(entry)) indices.append(str(entry))
return "%s{%s}" % (self.__class__.__name__, ", ".join(indices)) return "%s{%s}" % (self.__class__.__name__, ", ".join(indices))
...@@ -1731,24 +1732,13 @@ class SetSubtensor(Op): ...@@ -1731,24 +1732,13 @@ class SetSubtensor(Op):
indices = [] indices = []
for entry in self.idx_list: for entry in self.idx_list:
if isinstance(entry, slice): if isinstance(entry, slice):
msg = [] indices.append(Subtensor.str_from_slice(entry))
for x in [entry.start, entry.stop, entry.step]:
if x is None:
msg += ""
else:
msg += [str(x)]
indices.append(":".join(msg))
#backport
#indices.append(":".join("" if x is None else str(x) for x in [entry.start, entry.stop, entry.step]))
else: else:
indices.append(str(entry)) indices.append(str(entry))
if self.inplace: if self.inplace:
msg = 'Inplace' msg = 'Inplace'
else: else:
msg = '' msg = ''
#backport
#return "%s%s{%s}" % ('Inplace' if self.inplace else '',
return "%s%s{%s}" % (msg, return "%s%s{%s}" % (msg,
self.__class__.__name__, ", ".join(indices)) self.__class__.__name__, ", ".join(indices))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论