Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bee83a7a
提交
bee83a7a
authored
7月 10, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 of theano/gof/fg.py
上级
3ebd725a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
22 行删除
+20
-22
fg.py
theano/gof/fg.py
+20
-21
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/fg.py
浏览文件 @
bee83a7a
...
@@ -13,7 +13,6 @@ from theano.gof import graph
...
@@ -13,7 +13,6 @@ from theano.gof import graph
from
theano.gof
import
utils
from
theano.gof
import
utils
from
theano.gof
import
toolbox
from
theano.gof
import
toolbox
from
theano
import
config
from
theano
import
config
import
warnings
from
theano.compat
import
OrderedDict
from
theano.compat
import
OrderedDict
from
six
import
iteritems
,
itervalues
from
six
import
iteritems
,
itervalues
...
@@ -22,6 +21,7 @@ from theano.misc.ordered_set import OrderedSet
...
@@ -22,6 +21,7 @@ from theano.misc.ordered_set import OrderedSet
NullType
=
None
NullType
=
None
class
CachedConstantError
(
Exception
):
class
CachedConstantError
(
Exception
):
"""An exception thrown when we put in a FunctionGraph a Constant
"""An exception thrown when we put in a FunctionGraph a Constant
that is cached. This should not happen as the user can reuse this
that is cached. This should not happen as the user can reuse this
...
@@ -143,7 +143,7 @@ class FunctionGraph(utils.object2):
...
@@ -143,7 +143,7 @@ class FunctionGraph(utils.object2):
self
.
variable_locks
=
{}
self
.
variable_locks
=
{}
self
.
profile
=
None
self
.
profile
=
None
#
## Setup a Variable ##
#
#
Setup a Variable
#
def
__setup_r__
(
self
,
r
):
def
__setup_r__
(
self
,
r
):
# sets up r so it belongs to this fgraph
# sets up r so it belongs to this fgraph
if
getattr
(
r
,
'cached'
,
False
):
if
getattr
(
r
,
'cached'
,
False
):
...
@@ -152,12 +152,12 @@ class FunctionGraph(utils.object2):
...
@@ -152,12 +152,12 @@ class FunctionGraph(utils.object2):
" graph that has a cached constant. This should not happen."
" graph that has a cached constant. This should not happen."
" Clone the graph before building the FunctionGraph."
)
" Clone the graph before building the FunctionGraph."
)
if
(
hasattr
(
r
,
'fgraph'
)
and
if
(
hasattr
(
r
,
'fgraph'
)
and
r
.
fgraph
is
not
None
and
r
.
fgraph
is
not
None
and
r
.
fgraph
is
not
self
):
r
.
fgraph
is
not
self
):
raise
Exception
(
"
%
s is already owned by another fgraph"
%
r
)
raise
Exception
(
"
%
s is already owned by another fgraph"
%
r
)
r
.
fgraph
=
self
r
.
fgraph
=
self
r
.
clients
=
[]
r
.
clients
=
[]
#self.execute_callbacks('on_setup_variable', r)
#
self.execute_callbacks('on_setup_variable', r)
def
__setup_node__
(
self
,
node
):
def
__setup_node__
(
self
,
node
):
# sets up node so it belongs to this fgraph
# sets up node so it belongs to this fgraph
...
@@ -177,7 +177,7 @@ class FunctionGraph(utils.object2):
...
@@ -177,7 +177,7 @@ class FunctionGraph(utils.object2):
str
(
node
.
op
),
str
(
node
.
op
.
destroy_map
)))
str
(
node
.
op
),
str
(
node
.
op
.
destroy_map
)))
node
.
fgraph
=
self
node
.
fgraph
=
self
node
.
deps
=
{}
node
.
deps
=
{}
#self.execute_callbacks('on_setup_node', node)
#
self.execute_callbacks('on_setup_node', node)
def
disown
(
self
):
def
disown
(
self
):
""" WRITEME
""" WRITEME
...
@@ -201,7 +201,7 @@ class FunctionGraph(utils.object2):
...
@@ -201,7 +201,7 @@ class FunctionGraph(utils.object2):
self
.
inputs
=
None
self
.
inputs
=
None
self
.
outputs
=
None
self
.
outputs
=
None
#
## clients ##
#
#
clients
#
def
clients
(
self
,
r
):
def
clients
(
self
,
r
):
"""
"""
Set of all the (node, i) pairs such that node.inputs[i] is r.
Set of all the (node, i) pairs such that node.inputs[i] is r.
...
@@ -221,9 +221,9 @@ class FunctionGraph(utils.object2):
...
@@ -221,9 +221,9 @@ class FunctionGraph(utils.object2):
if
set
(
r
.
clients
)
.
intersection
(
set
(
new_clients
)):
if
set
(
r
.
clients
)
.
intersection
(
set
(
new_clients
)):
print
(
'ERROR: clients intersect!'
,
file
=
sys
.
stderr
)
print
(
'ERROR: clients intersect!'
,
file
=
sys
.
stderr
)
print
(
' RCLIENTS of'
,
r
,
[(
n
,
i
,
type
(
n
),
id
(
n
))
print
(
' RCLIENTS of'
,
r
,
[(
n
,
i
,
type
(
n
),
id
(
n
))
for
n
,
i
in
r
.
clients
],
file
=
sys
.
stderr
)
for
n
,
i
in
r
.
clients
],
file
=
sys
.
stderr
)
print
(
' NCLIENTS of'
,
r
,
[(
n
,
i
,
type
(
n
),
id
(
n
))
print
(
' NCLIENTS of'
,
r
,
[(
n
,
i
,
type
(
n
),
id
(
n
))
for
n
,
i
in
new_clients
],
file
=
sys
.
stderr
)
for
n
,
i
in
new_clients
],
file
=
sys
.
stderr
)
assert
not
set
(
r
.
clients
)
.
intersection
(
set
(
new_clients
))
assert
not
set
(
r
.
clients
)
.
intersection
(
set
(
new_clients
))
r
.
clients
+=
new_clients
r
.
clients
+=
new_clients
...
@@ -245,7 +245,7 @@ class FunctionGraph(utils.object2):
...
@@ -245,7 +245,7 @@ class FunctionGraph(utils.object2):
return
True
return
True
return
False
return
False
#
## import ##
#
#
import
#
def
__import_r__
(
self
,
variable
,
reason
):
def
__import_r__
(
self
,
variable
,
reason
):
global
NullType
global
NullType
if
NullType
is
None
:
if
NullType
is
None
:
...
@@ -279,9 +279,8 @@ class FunctionGraph(utils.object2):
...
@@ -279,9 +279,8 @@ class FunctionGraph(utils.object2):
if
hasattr
(
r
,
'fgraph'
)
and
r
.
fgraph
is
not
self
:
if
hasattr
(
r
,
'fgraph'
)
and
r
.
fgraph
is
not
self
:
raise
Exception
(
"
%
s is already owned by another fgraph"
%
r
)
raise
Exception
(
"
%
s is already owned by another fgraph"
%
r
)
if
(
r
.
owner
is
None
and
if
(
r
.
owner
is
None
and
not
isinstance
(
r
,
graph
.
Constant
)
and
not
isinstance
(
r
,
graph
.
Constant
)
and
r
not
in
self
.
inputs
):
r
not
in
self
.
inputs
):
# Verbose error message
# Verbose error message
# Show a complete chain of variables from the missing input to an output
# Show a complete chain of variables from the missing input to an output
if
config
.
exception_verbosity
==
'high'
:
if
config
.
exception_verbosity
==
'high'
:
...
@@ -373,7 +372,7 @@ class FunctionGraph(utils.object2):
...
@@ -373,7 +372,7 @@ class FunctionGraph(utils.object2):
assert
node
.
fgraph
is
self
assert
node
.
fgraph
is
self
self
.
execute_callbacks
(
'on_import'
,
node
,
reason
)
self
.
execute_callbacks
(
'on_import'
,
node
,
reason
)
#
## prune ##
#
#
prune
#
def
__prune_r__
(
self
,
variable
,
reason
=
None
):
def
__prune_r__
(
self
,
variable
,
reason
=
None
):
"""Should be called for variable that aren't used anymore:
"""Should be called for variable that aren't used anymore:
len(var.clients) == 0
len(var.clients) == 0
...
@@ -430,7 +429,7 @@ class FunctionGraph(utils.object2):
...
@@ -430,7 +429,7 @@ class FunctionGraph(utils.object2):
self
.
__remove_clients__
(
input
,
[(
apply_node
,
i
)],
reason
=
reason
)
self
.
__remove_clients__
(
input
,
[(
apply_node
,
i
)],
reason
=
reason
)
# self.__prune_r__(apply_node.inputs)
# self.__prune_r__(apply_node.inputs)
#
## change input ##
#
#
change input
#
def
change_input
(
self
,
node
,
i
,
new_r
,
reason
=
None
):
def
change_input
(
self
,
node
,
i
,
new_r
,
reason
=
None
):
"""WRITEME
"""WRITEME
Changes node.inputs[i] to new_r.
Changes node.inputs[i] to new_r.
...
@@ -475,7 +474,7 @@ class FunctionGraph(utils.object2):
...
@@ -475,7 +474,7 @@ class FunctionGraph(utils.object2):
if
prune
:
if
prune
:
self
.
__prune_r__
(
r
,
reason
=
reason
)
self
.
__prune_r__
(
r
,
reason
=
reason
)
#
## replace ##
#
#
replace
#
def
replace
(
self
,
r
,
new_r
,
reason
=
None
,
verbose
=
None
):
def
replace
(
self
,
r
,
new_r
,
reason
=
None
,
verbose
=
None
):
""" WRITEME
""" WRITEME
This is the main interface to manipulate the subgraph in FunctionGraph.
This is the main interface to manipulate the subgraph in FunctionGraph.
...
@@ -582,7 +581,7 @@ class FunctionGraph(utils.object2):
...
@@ -582,7 +581,7 @@ class FunctionGraph(utils.object2):
if
detach
is
not
None
:
if
detach
is
not
None
:
detach
(
self
)
detach
(
self
)
#
## callback utils ##
#
#
callback utils
#
def
execute_callbacks
(
self
,
name
,
*
args
,
**
kwargs
):
def
execute_callbacks
(
self
,
name
,
*
args
,
**
kwargs
):
"""WRITEME
"""WRITEME
Calls
Calls
...
@@ -618,7 +617,7 @@ class FunctionGraph(utils.object2):
...
@@ -618,7 +617,7 @@ class FunctionGraph(utils.object2):
d
[
feature
]
=
fn
(
*
args
)
d
[
feature
]
=
fn
(
*
args
)
return
d
return
d
#
## misc ##
#
#
misc
#
def
toposort
(
self
):
def
toposort
(
self
):
"""WRITEME
"""WRITEME
Returns an ordering of the graph's Apply nodes such that:
Returns an ordering of the graph's Apply nodes such that:
...
@@ -712,8 +711,8 @@ class FunctionGraph(utils.object2):
...
@@ -712,8 +711,8 @@ class FunctionGraph(utils.object2):
missing
,
excess
)
missing
,
excess
)
for
variable
in
variables
:
for
variable
in
variables
:
if
(
variable
.
owner
is
None
and
if
(
variable
.
owner
is
None
and
variable
not
in
self
.
inputs
and
variable
not
in
self
.
inputs
and
not
isinstance
(
variable
,
graph
.
Constant
)):
not
isinstance
(
variable
,
graph
.
Constant
)):
raise
Exception
(
"Undeclared input."
,
variable
)
raise
Exception
(
"Undeclared input."
,
variable
)
if
variable
.
fgraph
is
not
self
:
if
variable
.
fgraph
is
not
self
:
raise
Exception
(
"Variable should belong to the FunctionGraph."
,
raise
Exception
(
"Variable should belong to the FunctionGraph."
,
...
@@ -737,7 +736,7 @@ class FunctionGraph(utils.object2):
...
@@ -737,7 +736,7 @@ class FunctionGraph(utils.object2):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
__str__
()
return
self
.
__str__
()
#
## clone ##
#
#
clone
#
def
clone
(
self
,
check_integrity
=
True
):
def
clone
(
self
,
check_integrity
=
True
):
"""WRITEME"""
"""WRITEME"""
return
self
.
clone_get_equiv
(
check_integrity
)[
0
]
return
self
.
clone_get_equiv
(
check_integrity
)[
0
]
...
...
theano/tests/test_flake8.py
浏览文件 @
bee83a7a
...
@@ -243,7 +243,6 @@ whitelist_flake8 = [
...
@@ -243,7 +243,6 @@ whitelist_flake8 = [
"gof/unify.py"
,
"gof/unify.py"
,
"gof/graph.py"
,
"gof/graph.py"
,
"gof/__init__.py"
,
"gof/__init__.py"
,
"gof/fg.py"
,
"gof/op.py"
,
"gof/op.py"
,
"gof/cmodule.py"
,
"gof/cmodule.py"
,
"gof/tests/test_cmodule.py"
,
"gof/tests/test_cmodule.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论