提交 863677d0 authored 作者: Frederic's avatar Frederic

Move how pydot is imported and detected to respect pep8.

上级 7266073f
......@@ -7,6 +7,12 @@ import sys, os, StringIO
import numpy
try:
import pydot as pd
pydot_imported = True
except ImportError:
pydot_imported = False
import theano
import gof
from theano import config
......@@ -463,11 +469,9 @@ def pydotprint(fct, outfile=None,
raise ValueError(('pydotprint expects as input a theano.function or '
'the env of a function!'), fct)
try:
import pydot as pd
except ImportError:
print ("Failed to import pydot. You must install pydot for "
"`pydotprint` to work.")
if not pydot_imported:
raise RuntimeError ("Failed to import pydot. You must install pydot"
" for `pydotprint` to work.")
return
g=pd.Dot()
......
......@@ -22,9 +22,7 @@ def test_pydotprint_cond_highlight():
"""
# Skip test if pydot is not available.
try:
import pydot
except ImportError:
if not theano.printing.pydot_imported:
raise SkipTest('pydot not available')
x = tensor.dvector()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论