提交 1040bd3b authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Less aggressive restoration of warning settings in tests

上级 ea89ea63
......@@ -55,10 +55,15 @@ class TestComputeTestValue(unittest.TestCase):
# test that a warning is raised if required
theano.config.compute_test_value = 'warn'
warnings.simplefilter('error', UserWarning)
self.assertRaises(UserWarning, T.dot, x, y)
try:
self.assertRaises(UserWarning, T.dot, x, y)
finally:
# Restore the default behavior.
# TODO There is a cleaner way to do this in Python 2.6, once
# Theano drops support of Python 2.4 and 2.5.
warnings.simplefilter('default', UserWarning)
finally:
theano.config.compute_test_value = orig_compute_test_value
warnings.resetwarnings()
def test_string_var(self):
orig_compute_test_value = theano.config.compute_test_value
......
......@@ -348,13 +348,20 @@ def makeSharedTester(shared_constructor_,
action='ignore',
message='The .value property of shared variables is deprecated.'
)
nd += 1
old_data = x_shared.container.storage[0]
x_shared.value = nd
assert numpy.allclose(self.ref_fct(x_shared.value), self.ref_fct(self.cast_value(nd)))
assert may_share_memory(old_data, x_shared.container.storage[0]) == self.set_value_inplace
# restore the warning filters
warnings.resetwarnings()
try:
nd += 1
old_data = x_shared.container.storage[0]
x_shared.value = nd
assert numpy.allclose(self.ref_fct(x_shared.value), self.ref_fct(self.cast_value(nd)))
assert may_share_memory(old_data, x_shared.container.storage[0]) == self.set_value_inplace
finally:
# Restore the default behavior.
# TODO There is a cleaner way to do this in Python 2.6, once
# Theano drops support of Python 2.4 and 2.5.
warnings.filterwarnings(
action='default',
message='The .value property of shared variables is deprecated.'
)
# Test by set_value with borrow=False
nd += 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论