提交 bee83a7a authored 作者: Iban Harlouchet's avatar Iban Harlouchet

flake8 of theano/gof/fg.py

上级 3ebd725a
...@@ -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):
...@@ -157,7 +157,7 @@ class FunctionGraph(utils.object2): ...@@ -157,7 +157,7 @@ class FunctionGraph(utils.object2):
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.
...@@ -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:
...@@ -281,7 +281,6 @@ class FunctionGraph(utils.object2): ...@@ -281,7 +281,6 @@ class FunctionGraph(utils.object2):
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:
...@@ -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]
......
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论