提交 6cf9e0e8 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed test test_deepcopy_shared_container: it was the test's fault if it was failing

上级 b12d4c7b
...@@ -321,24 +321,27 @@ class T_picklefunction(unittest.TestCase): ...@@ -321,24 +321,27 @@ class T_picklefunction(unittest.TestCase):
def test_deepcopy_shared_container(self): def test_deepcopy_shared_container(self):
# Ensure that shared containers remain shared after a deep copy. # Ensure that shared containers remain shared after a deep copy.
a = T.scalar('a') a, x = T.scalars('ax')
x,s = T.scalars('xs')
h = function([In(a, value = 0.0)], a) h = function([In(a, value = 0.0)], a)
f = function([x, In(a, value=h.container[a], implicit = True)], x + a) f = function([x, In(a, value=h.container[a], implicit = True)], x + a)
try: try:
hc = copy.deepcopy(h) memo = {}
fc = copy.deepcopy(f, memo = {id(h): hc}) ac = copy.deepcopy(a)
memo.update({id(a): ac})
hc = copy.deepcopy(h, memo = memo)
memo.update({id(h): hc})
fc = copy.deepcopy(f, memo = memo)
except NotImplementedError, e: except NotImplementedError, e:
if e[0].startswith('DebugMode is not picklable'): if e[0].startswith('DebugMode is not picklable'):
return return
else: else:
raise raise
h[a] = 1 h[a] = 1
hc[a] = 2 hc[ac] = 2
self.failUnless(f[a] == 1) self.failUnless(f[a] == 1)
self.failUnless(fc[a] == 2) self.failUnless(fc[ac] == 2)
def test_pickle(self): def test_pickle(self):
a = T.scalar() # the a is for 'anonymous' (un-named). a = T.scalar() # the a is for 'anonymous' (un-named).
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论