Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3a4474c8
提交
3a4474c8
authored
3月 28, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sort the histograph of keys and code file. Add an option to print the keys that…
sort the histograph of keys and code file. Add an option to print the keys that give the most frequently the same c code.
上级
c3c5d8a9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
17 行删除
+33
-17
check_duplicate_key.py
theano/misc/check_duplicate_key.py
+33
-17
没有找到文件。
theano/misc/check_duplicate_key.py
浏览文件 @
3a4474c8
import
p
ickle
import
cP
ickle
import
os
,
sys
import
theano
DISPLAY_DUPLICATE_KEYS
=
False
DISPLAY_MOST_FREQUENT_DUPLICATE_CCODE
=
False
dirs
=
[]
if
len
(
sys
.
argv
)
>
1
:
...
...
@@ -16,13 +17,13 @@ keys = {} # key -> nb seen
mods
=
{}
for
dir
in
dirs
:
key
=
None
try
:
f
=
open
(
os
.
path
.
join
(
dir
,
"key.pkl"
))
key
=
f
.
read
()
f
.
close
()
keys
.
setdefault
(
key
,
0
)
keys
[
key
]
+=
1
del
key
del
f
except
IOError
:
#print dir, "don't have a key.pkl file"
...
...
@@ -34,8 +35,8 @@ for dir in dirs:
f
=
open
(
path
)
mod
=
f
.
read
()
f
.
close
()
mods
.
setdefault
(
mod
,
0
)
mods
[
mod
]
+=
1
mods
.
setdefault
(
mod
,
()
)
mods
[
mod
]
+=
(
key
,)
del
mod
del
f
del
path
...
...
@@ -46,27 +47,42 @@ for dir in dirs:
if
DISPLAY_DUPLICATE_KEYS
:
for
k
,
v
in
keys
.
iteritems
():
if
v
>
1
:
print
"Duplicate key (
%
i copies):
%
s"
%
(
v
,
p
ickle
.
loads
(
k
))
print
"Duplicate key (
%
i copies):
%
s"
%
(
v
,
cP
ickle
.
loads
(
k
))
nbs
=
{}
# nb seen -> now many key
nbs
_keys
=
{}
# nb seen -> now many key
for
val
in
keys
.
values
():
nbs
.
setdefault
(
val
,
0
)
nbs
[
val
]
+=
1
nbs
_keys
.
setdefault
(
val
,
0
)
nbs
_keys
[
val
]
+=
1
print
"key.pkl histograph"
print
nbs
nbs
=
{}
# nb seen -> now many key
nbs_mod
=
{}
# nb seen -> how many key
nbs_mod_to_key
=
{}
#nb seen -> keys
more_then_one
=
0
for
val
in
mods
.
values
():
nbs
.
setdefault
(
val
,
0
)
nbs
[
val
]
+=
1
for
mod
,
kk
in
mods
.
iteritems
():
val
=
len
(
kk
)
nbs_mod
.
setdefault
(
val
,
0
)
nbs_mod
[
val
]
+=
1
if
val
>
1
:
more_then_one
+=
1
nbs_mod_to_key
[
val
]
=
kk
if
DISPLAY_MOST_FREQUENT_DUPLICATE_CCODE
:
m
=
max
(
nbs_mod
.
keys
())
print
"The keys associated to the mod.{cpp,cu} with the most number of copy:"
for
kk
in
nbs_mod_to_key
[
m
]:
kk
=
cPickle
.
loads
(
kk
)
print
kk
print
"key.pkl histograph"
l
=
nbs_keys
.
items
()
l
.
sort
()
print
l
print
"mod.{cpp,cu} histogram"
print
nbs
total
=
sum
(
mods
.
values
())
l
=
nbs_mod
.
items
()
l
.
sort
()
print
l
total
=
sum
([
len
(
k
)
for
k
in
mods
.
values
()])
uniq
=
len
(
mods
)
useless
=
total
-
uniq
print
"mod.{cpp,cu} total:"
,
total
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论