提交 3cce5a48 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

added debug_assert, fixed a missing not

上级 ca01fca9
...@@ -604,6 +604,20 @@ def debug_error_message(msg): ...@@ -604,6 +604,20 @@ def debug_error_message(msg):
assert action == 'warn' assert action == 'warn'
warnings.warn(msg, stacklevel = 2) warnings.warn(msg, stacklevel = 2)
def debug_assert(condition, msg):
if not condition:
action = config.compute_test_value
if action in ['raise', 'ignore']:
raise AssertionError(msg)
else:
assert action == 'warn'
warnings.warn(msg, stacklevel = 2)
def get_debug_values(*args): def get_debug_values(*args):
""" Given a list of variables, does one of three things: """ Given a list of variables, does one of three things:
...@@ -614,7 +628,7 @@ def get_debug_values(*args): ...@@ -614,7 +628,7 @@ def get_debug_values(*args):
This single element is a tuple containing debug values of This single element is a tuple containing debug values of
all the variables. all the variables.
3. If the interactive debugger is on, and some variable does 3. If the interactive debugger is on, and some variable does
have a debug value, issue a missing_test_message about not have a debug value, issue a missing_test_message about
the variable, and, if still in control of execution, return the variable, and, if still in control of execution, return
an empty list an empty list
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论