提交 5dd4c64a authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Merge pull request #164 from nouiz/pep8

Pep8 I've looked over it and everything seems fine.
差异被折叠。
...@@ -22,14 +22,12 @@ def test_pydotprint_cond_highlight(): ...@@ -22,14 +22,12 @@ def test_pydotprint_cond_highlight():
""" """
# Skip test if pydot is not available. # Skip test if pydot is not available.
try: if not theano.printing.pydot_imported:
import pydot
except ImportError:
raise SkipTest('pydot not available') raise SkipTest('pydot not available')
x = tensor.dvector() x = tensor.dvector()
f = theano.function([x], x*2) f = theano.function([x], x * 2)
f([1,2,3,4]) f([1, 2, 3, 4])
s = StringIO.StringIO() s = StringIO.StringIO()
new_handler = logging.StreamHandler(s) new_handler = logging.StreamHandler(s)
...@@ -39,19 +37,21 @@ def test_pydotprint_cond_highlight(): ...@@ -39,19 +37,21 @@ def test_pydotprint_cond_highlight():
theano.theano_logger.removeHandler(orig_handler) theano.theano_logger.removeHandler(orig_handler)
theano.theano_logger.addHandler(new_handler) theano.theano_logger.addHandler(new_handler)
try: try:
theano.printing.pydotprint(f, cond_highlight = True, print_output_file=False) theano.printing.pydotprint(f, cond_highlight=True,
print_output_file=False)
finally: finally:
theano.theano_logger.addHandler(orig_handler) theano.theano_logger.addHandler(orig_handler)
theano.theano_logger.removeHandler(new_handler) theano.theano_logger.removeHandler(new_handler)
assert s.getvalue() == 'pydotprint: cond_highlight is set but there is no IfElse node in the graph\n' assert (s.getvalue() == 'pydotprint: cond_highlight is set but there'
' is no IfElse node in the graph\n')
def test_pydotprint_profile(): def test_pydotprint_profile():
"""Just check that pydotprint does not crash with ProfileMode.""" """Just check that pydotprint does not crash with ProfileMode."""
A = tensor.matrix() A = tensor.matrix()
f = theano.function([A], A+1, mode='ProfileMode') f = theano.function([A], A + 1, mode='ProfileMode')
theano.printing.pydotprint(f, print_output_file=False) theano.printing.pydotprint(f, print_output_file=False)
...@@ -59,26 +59,26 @@ def test_min_informative_str(): ...@@ -59,26 +59,26 @@ def test_min_informative_str():
""" evaluates a reference output to make sure the """ evaluates a reference output to make sure the
min_informative_str function works as intended """ min_informative_str function works as intended """
A = tensor.matrix(name = 'A') A = tensor.matrix(name='A')
B = tensor.matrix(name = 'B') B = tensor.matrix(name='B')
C = A + B C = A + B
C.name = 'C' C.name = 'C'
D = tensor.matrix(name = 'D') D = tensor.matrix(name='D')
E = tensor.matrix(name = 'E') E = tensor.matrix(name='E')
F = D + E F = D + E
G = C + F G = C + F
mis = min_informative_str(G) mis = min_informative_str(G).replace("\t", " ")
reference = """A. Elemwise{add,no_inplace} reference = """A. Elemwise{add,no_inplace}
B. C B. C
C. Elemwise{add,no_inplace} C. Elemwise{add,no_inplace}
D. D D. D
E. E""" E. E"""
if mis != reference: if mis != reference:
print '--'+mis+'--' print '--' + mis + '--'
print '--'+reference+'--' print '--' + reference + '--'
assert mis == reference assert mis == reference
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论