提交 02c21c5b authored 作者: Frederic's avatar Frederic

Fix a test if vm.lazy=False, it expect it to be True.

上级 6a93ccc7
......@@ -89,6 +89,37 @@ theano_raw_cfg = ConfigParser.RawConfigParser()
theano_raw_cfg.read(config_files)
def change_flags(**kwargs):
"""
Use this as a decorator to change the value of Theano config variable.
Useful during tests.
"""
def change_flags_exec(f):
def inner(*args, **kwargs_):
old_val = {}
for k in kwargs:
l = [v for v in theano.configparser._config_var_list
if v.fullname == k]
assert len(l) == 1
old_val[k] = l[0].__get__()
try:
for k in kwargs:
l = [v for v in theano.configparser._config_var_list
if v.fullname == k]
assert len(l) == 1
l[0].__set__(None, kwargs[k])
return f(*args, **kwargs_)
finally:
for k in kwargs:
l = [v for v in theano.configparser._config_var_list
if v.fullname == k]
assert len(l) == 1
l[0].__set__(None, old_val[k])
return inner
return change_flags_exec
def fetch_val_for_key(key):
"""Return the overriding config value for a key.
A successful search returns a string value.
......
......@@ -122,6 +122,7 @@ def test_memory():
assert mem1 == freemem(), (mem1, freemem())
@theano.configparser.change_flags(**{'vm.lazy': True})
def test_memory_lazy():
"""As test_memory, but with the ifelse op.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论