Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
458e1594
提交
458e1594
authored
12月 15, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3772 from gw0/feat-pydot-fallback
Import pydot-ng with pydot as fallback.
上级
2bac5a41
2fa6f48e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
23 行增加
和
33 行删除
+23
-33
__init__.py
theano/d3viz/__init__.py
+0
-8
formatting.py
theano/d3viz/formatting.py
+9
-2
test_d3viz.py
theano/d3viz/tests/test_d3viz.py
+2
-2
test_formatting.py
theano/d3viz/tests/test_formatting.py
+2
-2
printing.py
theano/printing.py
+10
-19
没有找到文件。
theano/d3viz/__init__.py
浏览文件 @
458e1594
from
theano.d3viz.d3viz
import
d3viz
,
d3write
from
theano.d3viz.d3viz
import
d3viz
,
d3write
has_requirements
=
False
try
:
import
pydot
as
pd
if
pd
.
find_graphviz
():
has_requirements
=
True
except
ImportError
:
pass
theano/d3viz/formatting.py
浏览文件 @
458e1594
...
@@ -16,11 +16,18 @@ from theano.compile import builders
...
@@ -16,11 +16,18 @@ from theano.compile import builders
pydot_imported
=
False
pydot_imported
=
False
try
:
try
:
import
pydot
as
pd
# pydot-ng is a fork of pydot that is better maintained
import
pydot_ng
as
pd
if
pd
.
find_graphviz
():
if
pd
.
find_graphviz
():
pydot_imported
=
True
pydot_imported
=
True
except
ImportError
:
except
ImportError
:
pass
try
:
# fall back on pydot if necessary
import
pydot
as
pd
if
pd
.
find_graphviz
():
pydot_imported
=
True
except
ImportError
:
pass
# tests should not fail on optional dependency
class
PyDotFormatter
(
object
):
class
PyDotFormatter
(
object
):
...
...
theano/d3viz/tests/test_d3viz.py
浏览文件 @
458e1594
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
theano.d3viz
import
has_requirements
from
theano.d3viz
.formatting
import
pydot_imported
if
not
has_requirements
:
if
not
pydot_imported
:
raise
SkipTest
(
'Missing requirements'
)
raise
SkipTest
(
'Missing requirements'
)
import
numpy
as
np
import
numpy
as
np
...
...
theano/d3viz/tests/test_formatting.py
浏览文件 @
458e1594
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
theano.d3viz
import
has_requirements
from
theano.d3viz
.formatting
import
pydot_imported
if
not
has_requirements
:
if
not
pydot_imported
:
raise
SkipTest
(
'Missing requirements'
)
raise
SkipTest
(
'Missing requirements'
)
import
numpy
as
np
import
numpy
as
np
...
...
theano/printing.py
浏览文件 @
458e1594
...
@@ -22,25 +22,20 @@ from theano.gof import Op, Apply
...
@@ -22,25 +22,20 @@ from theano.gof import Op, Apply
from
theano.compile
import
Function
,
debugmode
,
SharedVariable
from
theano.compile
import
Function
,
debugmode
,
SharedVariable
from
theano.compile.profilemode
import
ProfileMode
from
theano.compile.profilemode
import
ProfileMode
# pydot-ng is a fork of pydot that is better maintained, and works
pydot_imported
=
False
# with more recent version of its dependencies (in particular pyparsing)
try
:
try
:
# pydot-ng is a fork of pydot that is better maintained
import
pydot_ng
as
pd
import
pydot_ng
as
pd
if
pd
.
find_graphviz
():
if
pd
.
find_graphviz
():
pydot_imported
=
True
pydot_imported
=
True
else
:
except
ImportError
:
pydot_imported
=
False
except
Exception
:
# Sometimes, a Windows-specific exception is raised
pydot_imported
=
False
# Fall back on pydot if necessary
if
not
pydot_imported
:
try
:
try
:
# fall back on pydot if necessary
import
pydot
as
pd
import
pydot
as
pd
if
pd
.
find_graphviz
():
if
pd
.
find_graphviz
():
pydot_imported
=
True
pydot_imported
=
True
except
Exception
:
except
ImportError
:
pass
pass
# tests should not fail on optional dependency
_logger
=
logging
.
getLogger
(
"theano.printing"
)
_logger
=
logging
.
getLogger
(
"theano.printing"
)
VALID_ASSOC
=
set
([
'left'
,
'right'
,
'either'
])
VALID_ASSOC
=
set
([
'left'
,
'right'
,
'either'
])
...
@@ -733,7 +728,6 @@ def pydotprint(fct, outfile=None,
...
@@ -733,7 +728,6 @@ def pydotprint(fct, outfile=None,
if
not
pydot_imported
:
if
not
pydot_imported
:
raise
RuntimeError
(
"Failed to import pydot. You must install pydot"
raise
RuntimeError
(
"Failed to import pydot. You must install pydot"
" and graphviz for `pydotprint` to work."
)
" and graphviz for `pydotprint` to work."
)
return
g
=
pd
.
Dot
()
g
=
pd
.
Dot
()
...
@@ -1065,13 +1059,10 @@ def pydotprint_variables(vars,
...
@@ -1065,13 +1059,10 @@ def pydotprint_variables(vars,
if
outfile
is
None
:
if
outfile
is
None
:
outfile
=
os
.
path
.
join
(
config
.
compiledir
,
'theano.pydotprint.'
+
outfile
=
os
.
path
.
join
(
config
.
compiledir
,
'theano.pydotprint.'
+
config
.
device
+
'.'
+
format
)
config
.
device
+
'.'
+
format
)
try
:
if
not
pydot_imported
:
import
pydot
as
pd
raise
RuntimeError
(
"Failed to import pydot. You must install pydot"
except
ImportError
:
" and graphviz for `pydotprint_variables` to work."
)
err
=
(
"Failed to import pydot. You must install pydot for "
+
"`pydotprint_variables` to work."
)
print
(
err
)
return
g
=
pd
.
Dot
()
g
=
pd
.
Dot
()
my_list
=
{}
my_list
=
{}
orphanes
=
[]
orphanes
=
[]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论