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

debugprint now stop printing the "|" symbol in a columns after the last input.

上级 ec0e7537
......@@ -24,6 +24,7 @@ New Feature
as this is more readable.
* debugprint new param stop_on_name=[False,True]. If True, we don't print
anything bellow an intermediate variable that have a name. Default to False.
* debugprint now stop printing the "|" symbol in a columns after the last input.
=============
Release Notes
......
......@@ -502,7 +502,8 @@ def char_from_number(number):
def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
file=sys.stdout, print_destroy_map=False, print_view_map=False,
order=[], ids='CHAR', stop_on_name=False):
order=[], ids='CHAR', stop_on_name=False,
prefix_child=None):
"""Print the graph leading to `r` to given depth.
:param r: Variable instance
......@@ -535,6 +536,9 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
else:
type_str = ''
if prefix_child is None:
prefix_child = prefix
def get_id_str(obj):
if obj in done:
id_str = "[@%s]" % done[obj]
......@@ -598,10 +602,16 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
if not already_printed:
if (not stop_on_name or
not (hasattr(r, 'name') and r.name is not None)):
for i in a.inputs:
debugprint(i, prefix + ' |', depth=depth - 1, done=done,
new_prefix = prefix_child + ' |'
new_prefix_child = prefix_child + ' |'
for idx, i in enumerate(a.inputs):
if idx == len(a.inputs) - 1:
new_prefix_child = prefix_child + ' '
debugprint(i, new_prefix, depth=depth - 1, done=done,
print_type=print_type, file=file, order=order,
ids=ids, stop_on_name=stop_on_name)
ids=ids, stop_on_name=stop_on_name,
prefix_child=new_prefix_child)
else:
#this is an input variable
id_str = get_id_str(r)
......
......@@ -112,8 +112,8 @@ def test_debugprint():
| |A [@2]
| |B [@3]
|Elemwise{add,no_inplace} [@4] ''
| |D [@5]
| |E [@6]
|D [@5]
|E [@6]
"""
if s != reference:
......@@ -132,8 +132,8 @@ def test_debugprint():
| |A [@C]
| |B [@D]
|Elemwise{add,no_inplace} [@E] ''
| |D [@F]
| |E [@G]
|D [@F]
|E [@G]
"""
if s != reference:
......@@ -151,8 +151,8 @@ def test_debugprint():
reference = """Elemwise{add,no_inplace} [@A] ''
|Elemwise{add,no_inplace} [@B] 'C'
|Elemwise{add,no_inplace} [@C] ''
| |D [@D]
| |E [@E]
|D [@D]
|E [@E]
"""
if s != reference:
......@@ -172,8 +172,8 @@ def test_debugprint():
| |A
| |B
|Elemwise{add,no_inplace} ''
| |D
| |E
|D
|E
"""
if s != reference:
print '--'+s+'--'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论