Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
722071d4
提交
722071d4
authored
5月 13, 2016
作者:
Mikhail Korobov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
d3viz: fix escaping of dot graph. Fixes GH-4510.
上级
13b76018
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
12 行删除
+10
-12
d3viz.py
theano/d3viz/d3viz.py
+9
-11
template.html
theano/d3viz/html/template.html
+1
-1
没有找到文件。
theano/d3viz/d3viz.py
浏览文件 @
722071d4
...
...
@@ -5,8 +5,8 @@ Author: Christof Angermueller <cangermueller@gmail.com>
from
__future__
import
absolute_import
,
print_function
,
division
import
os
import
json
import
shutil
import
re
import
six
from
six
import
iteritems
...
...
@@ -31,16 +31,15 @@ def replace_patterns(x, replace):
return
x
def
escape_quotes
(
s
):
"""E
scape quotes in string
.
def
safe_json
(
obj
):
"""E
ncode `obj` to JSON so that it can be embedded safely inside HTML
.
Parameters
----------
s : str
String on which function is applied
obj : object
object to serialize
"""
s
=
re
.
sub
(
r'''(['"])'''
,
r'\\\1'
,
s
)
return
s
return
json
.
dumps
(
obj
)
.
replace
(
'<'
,
'
\\
u003c'
)
def
d3viz
(
fct
,
outfile
,
copy_deps
=
True
,
*
args
,
**
kwargs
):
...
...
@@ -79,10 +78,9 @@ def d3viz(fct, outfile, copy_deps=True, *args, **kwargs):
# Create DOT graph
formatter
=
PyDotFormatter
(
*
args
,
**
kwargs
)
graph
=
formatter
(
fct
)
dot_graph
_raw
=
graph
.
create_dot
()
dot_graph
=
graph
.
create_dot
()
if
not
six
.
PY2
:
dot_graph_raw
=
dot_graph_raw
.
decode
(
'utf8'
)
dot_graph
=
escape_quotes
(
dot_graph_raw
)
.
replace
(
'
\n
'
,
''
)
.
replace
(
'
\r
'
,
''
)
dot_graph
=
dot_graph
.
decode
(
'utf8'
)
# Create output directory if not existing
outdir
=
os
.
path
.
dirname
(
outfile
)
...
...
@@ -109,7 +107,7 @@ def d3viz(fct, outfile, copy_deps=True, *args, **kwargs):
replace
=
{
'
%%
JS_DIR
%%
'
:
os
.
path
.
join
(
dst_deps
,
'js'
),
'
%%
CSS_DIR
%%
'
:
os
.
path
.
join
(
dst_deps
,
'css'
),
'
%%
DOT_GRAPH
%%
'
:
dot_graph
,
'
%%
DOT_GRAPH
%%
'
:
safe_json
(
dot_graph
)
,
}
html
=
replace_patterns
(
template
,
replace
)
...
...
theano/d3viz/html/template.html
浏览文件 @
722071d4
...
...
@@ -23,7 +23,7 @@
<script
type=
"text/javascript"
>
// Backend graph in DOT format
var
dotGraph
=
graphlibDot
.
read
(
"%% DOT_GRAPH %%"
);
var
dotGraph
=
graphlibDot
.
read
(
%%
DOT_GRAPH
%%
);
// Frontend graph for visualization
var
graph
=
{};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论