提交 de485e77 authored 作者: Frederic's avatar Frederic

Make work around work when readonly is True.

上级 d7bfe9f5
...@@ -334,7 +334,11 @@ class Container(object): ...@@ -334,7 +334,11 @@ class Container(object):
not self.type.is_valid_value(r.storage[0])): not self.type.is_valid_value(r.storage[0])):
assert not data_was_in_memo assert not data_was_in_memo
r.data = r.storage[0] assert self.type.is_valid_value(self.storage[0])
# This should also work for read only container.
r.storage[0] = self.type.filter(r.storage[0],
strict=False,
allow_downcast=False)
memo[id(self.storage[0])] = r.storage[0] memo[id(self.storage[0])] = r.storage[0]
return r return r
......
...@@ -193,7 +193,8 @@ def test_container_deepcopy(): ...@@ -193,7 +193,8 @@ def test_container_deepcopy():
""" """
t = theano.tensor.scalar() t = theano.tensor.scalar()
v = numpy.asarray(0.) v = numpy.asarray(0.)
c = Container(t, [v]) for readonly in [True, False]:
assert isinstance(c.storage[0], numpy.ndarray) c = Container(t, [v], readonly=readonly)
d = deepcopy(c) assert isinstance(c.storage[0], numpy.ndarray)
assert isinstance(d.storage[0], numpy.ndarray) d = deepcopy(c)
assert isinstance(d.storage[0], numpy.ndarray)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论