Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
52843bcb
提交
52843bcb
authored
5月 23, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Flake8 for gof/utils.py
上级
e0749882
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
19 行删除
+16
-19
utils.py
theano/gof/utils.py
+16
-18
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/utils.py
浏览文件 @
52843bcb
from
__future__
import
print_function
from
__future__
import
print_function
import
linecache
import
linecache
import
traceback
import
traceback
import
re
import
sys
import
sys
from
theano
import
config
from
theano
import
config
...
@@ -15,7 +14,6 @@ def simple_extract_stack(f=None, limit=None):
...
@@ -15,7 +14,6 @@ def simple_extract_stack(f=None, limit=None):
This is because this update cause an call to os.stat to get the
This is because this update cause an call to os.stat to get the
line content. This cause too much long on cluster.
line content. This cause too much long on cluster.
"""
"""
if
f
is
None
:
if
f
is
None
:
try
:
try
:
...
@@ -48,7 +46,7 @@ if sys.version_info[:2] > (3, 4):
...
@@ -48,7 +46,7 @@ if sys.version_info[:2] > (3, 4):
# I enable my implementation only for some python version just to
# I enable my implementation only for some python version just to
# be sure the Python internal do not change. If this work with
# be sure the Python internal do not change. If this work with
# other python version, you can enable it.
# other python version, you can enable it.
simple_extract_stack
=
traceback
.
extract_stack
simple_extract_stack
=
traceback
.
extract_stack
# noqa
def
add_tag_trace
(
thing
,
user_line
=
1
):
def
add_tag_trace
(
thing
,
user_line
=
1
):
...
@@ -81,7 +79,7 @@ def add_tag_trace(thing, user_line=1):
...
@@ -81,7 +79,7 @@ def add_tag_trace(thing, user_line=1):
"theano/scan_module/"
,
"theano/scan_module/"
,
"theano/sparse/"
,
"theano/sparse/"
,
"theano/typed_list/"
,
"theano/typed_list/"
,
]:
]:
if
p
in
file_path
:
if
p
in
file_path
:
tr
=
tr
[:
-
1
]
tr
=
tr
[:
-
1
]
rm
=
True
rm
=
True
...
@@ -190,8 +188,8 @@ def deprecated(filename, msg=''):
...
@@ -190,8 +188,8 @@ def deprecated(filename, msg=''):
def
g
(
*
args
,
**
kwargs
):
def
g
(
*
args
,
**
kwargs
):
if
printme
[
0
]:
if
printme
[
0
]:
print
(
'WARNING:
%
s.
%
s deprecated.
%
s'
\
print
(
'WARNING:
%
s.
%
s deprecated.
%
s'
%
%
(
filename
,
f
.
__name__
,
msg
))
(
filename
,
f
.
__name__
,
msg
))
printme
[
0
]
=
False
printme
[
0
]
=
False
return
f
(
*
args
,
**
kwargs
)
return
f
(
*
args
,
**
kwargs
)
return
g
return
g
...
@@ -220,7 +218,7 @@ def difference(seq1, seq2):
...
@@ -220,7 +218,7 @@ def difference(seq1, seq2):
raise
Exception
(
'not worth it'
)
raise
Exception
(
'not worth it'
)
set2
=
set
(
seq2
)
set2
=
set
(
seq2
)
return
[
x
for
x
in
seq1
if
x
not
in
set2
]
return
[
x
for
x
in
seq1
if
x
not
in
set2
]
except
Exception
as
e
:
except
Exception
:
# maybe a seq2 element is not hashable
# maybe a seq2 element is not hashable
# maybe seq2 is too short
# maybe seq2 is too short
# -> use O(len(seq1) * len(seq2)) algo
# -> use O(len(seq1) * len(seq2)) algo
...
@@ -311,11 +309,11 @@ def comm_guard(type1, type2):
...
@@ -311,11 +309,11 @@ def comm_guard(type1, type2):
old_f
=
f
.
func_globals
[
f
.
__name__
]
old_f
=
f
.
func_globals
[
f
.
__name__
]
def
new_f
(
arg1
,
arg2
,
*
rest
):
def
new_f
(
arg1
,
arg2
,
*
rest
):
if
(
type1
is
ANY_TYPE
or
isinstance
(
arg1
,
type1
))
\
if
(
(
type1
is
ANY_TYPE
or
isinstance
(
arg1
,
type1
))
and
and
(
type2
is
ANY_TYPE
or
isinstance
(
arg2
,
type2
)):
(
type2
is
ANY_TYPE
or
isinstance
(
arg2
,
type2
)
)):
pass
pass
elif
(
type1
is
ANY_TYPE
or
isinstance
(
arg2
,
type1
))
\
elif
(
(
type1
is
ANY_TYPE
or
isinstance
(
arg2
,
type1
))
and
and
(
type2
is
ANY_TYPE
or
isinstance
(
arg1
,
type2
)):
(
type2
is
ANY_TYPE
or
isinstance
(
arg1
,
type2
)
)):
arg1
,
arg2
=
arg2
,
arg1
arg1
,
arg2
=
arg2
,
arg1
else
:
else
:
return
old_f
(
arg1
,
arg2
,
*
rest
)
return
old_f
(
arg1
,
arg2
,
*
rest
)
...
@@ -337,8 +335,9 @@ def comm_guard(type1, type2):
...
@@ -337,8 +335,9 @@ def comm_guard(type1, type2):
return
type
.
__name__
return
type
.
__name__
new_f
.
__doc__
=
(
str
(
old_f
.
__doc__
)
+
"
\n
"
+
new_f
.
__doc__
=
(
str
(
old_f
.
__doc__
)
+
"
\n
"
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,
type2
)])
+
", "
.
join
([
typename
(
type
)
"
\n
"
+
str
(
f
.
__doc__
or
""
))
for
type
in
(
type1
,
type2
)])
+
"
\n
"
+
str
(
f
.
__doc__
or
""
))
return
new_f
return
new_f
return
wrap
return
wrap
...
@@ -369,8 +368,8 @@ def type_guard(type1):
...
@@ -369,8 +368,8 @@ def type_guard(type1):
return
type
.
__name__
return
type
.
__name__
new_f
.
__doc__
=
(
str
(
old_f
.
__doc__
)
+
"
\n
"
+
new_f
.
__doc__
=
(
str
(
old_f
.
__doc__
)
+
"
\n
"
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,)])
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,)])
+
"
\n
"
+
str
(
f
.
__doc__
or
""
))
"
\n
"
+
str
(
f
.
__doc__
or
""
))
return
new_f
return
new_f
return
wrap
return
wrap
...
@@ -412,9 +411,8 @@ def give_variables_names(variables):
...
@@ -412,9 +411,8 @@ def give_variables_names(variables):
var
.
name
=
(
var
.
name
or
""
)
+
"_
%
d"
%
i
var
.
name
=
(
var
.
name
or
""
)
+
"_
%
d"
%
i
if
not
unique
(
map
(
str
,
variables
)):
if
not
unique
(
map
(
str
,
variables
)):
raise
ValueError
(
"Not all variables have unique names."
raise
ValueError
(
"Not all variables have unique names. Maybe you've "
"Maybe you've named some of the variables identically"
)
"named some of the variables identically"
)
return
variables
return
variables
...
...
theano/tests/test_flake8.py
浏览文件 @
52843bcb
...
@@ -269,7 +269,6 @@ whitelist_flake8 = [
...
@@ -269,7 +269,6 @@ whitelist_flake8 = [
"sparse/sandbox/sp.py"
,
"sparse/sandbox/sp.py"
,
"gof/destroyhandler.py"
,
"gof/destroyhandler.py"
,
"gof/unify.py"
,
"gof/unify.py"
,
"gof/utils.py"
,
"gof/graph.py"
,
"gof/graph.py"
,
"gof/callcache.py"
,
"gof/callcache.py"
,
"gof/type.py"
,
"gof/type.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论