提交 eac844fc authored 作者: Olivier Delalleau's avatar Olivier Delalleau

PEP8

上级 0684ff58
...@@ -781,7 +781,6 @@ class SanityCheckFunction(Function): ...@@ -781,7 +781,6 @@ class SanityCheckFunction(Function):
return variables return variables
### ###
### FunctionMaker ### FunctionMaker
### ###
...@@ -813,12 +812,12 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs): ...@@ -813,12 +812,12 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
view_tree_set(alias_root(fgraph.outputs[i]), views_of_output_i) view_tree_set(alias_root(fgraph.outputs[i]), views_of_output_i)
copied = False copied = False
# do not allow outputs to be aliased # do not allow outputs to be aliased
for j in xrange(i+1, len(fgraph.outputs)): for j in xrange(i + 1, len(fgraph.outputs)):
# We could don't put deep copy if both outputs have borrow==True # We could don't put deep copy if both outputs have borrow==True
# and not(wrapped_outputs[i].borrow and wrapped_outputs[j].borrow): # and not(wrapped_outputs[i].borrow and wrapped_outputs[j].borrow):
if fgraph.outputs[j] in views_of_output_i: if fgraph.outputs[j] in views_of_output_i:
if wrapped_outputs[i].borrow and wrapped_outputs[j].borrow: if wrapped_outputs[i].borrow and wrapped_outputs[j].borrow:
fgraph.change_input('output',i, view_op(fgraph.outputs[i]), fgraph.change_input('output', i, view_op(fgraph.outputs[i]),
reason=reason) reason=reason)
else: else:
fgraph.change_input('output', i, deep_copy_op(fgraph.outputs[i]), fgraph.change_input('output', i, deep_copy_op(fgraph.outputs[i]),
...@@ -831,7 +830,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs): ...@@ -831,7 +830,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
# do not allow outputs to be aliased to an inputs (j), unless # do not allow outputs to be aliased to an inputs (j), unless
# a) that j'th input has been 'destroyed' by e.g. in-place computations # a) that j'th input has been 'destroyed' by e.g. in-place computations
# b) that j'th input is a shared variable that is also being updated # b) that j'th input is a shared variable that is also being updated
if hasattr(fgraph,'get_destroyers_of') and fgraph.get_destroyers_of(input_j): if (hasattr(fgraph, 'get_destroyers_of') and
fgraph.get_destroyers_of(input_j)):
continue continue
if input_j in updated_fgraph_inputs: if input_j in updated_fgraph_inputs:
continue continue
...@@ -840,7 +840,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs): ...@@ -840,7 +840,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
if input_j in fgraph.inputs: if input_j in fgraph.inputs:
j = fgraph.inputs.index(input_j) j = fgraph.inputs.index(input_j)
if wrapped_outputs[i].borrow and wrapped_inputs[j].borrow: if wrapped_outputs[i].borrow and wrapped_inputs[j].borrow:
fgraph.change_input('output',i, view_op(fgraph.outputs[i]), fgraph.change_input('output', i, view_op(fgraph.outputs[i]),
reason="insert_deepcopy") reason="insert_deepcopy")
break break
else: else:
...@@ -848,7 +848,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs): ...@@ -848,7 +848,7 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
reason="insert_deepcopy") reason="insert_deepcopy")
break break
elif wrapped_outputs[i].borrow: elif wrapped_outputs[i].borrow:
fgraph.change_input('output',i, view_op(fgraph.outputs[i]), fgraph.change_input('output', i, view_op(fgraph.outputs[i]),
reason="insert_deepcopy") reason="insert_deepcopy")
break break
else: else:
...@@ -857,6 +857,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs): ...@@ -857,6 +857,8 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
break break
NODEFAULT = ['NODEFAULT'] NODEFAULT = ['NODEFAULT']
class FunctionMaker(object): class FunctionMaker(object):
"""`FunctionMaker` is the class to `create` `Function` instances. """`FunctionMaker` is the class to `create` `Function` instances.
...@@ -876,7 +878,7 @@ class FunctionMaker(object): ...@@ -876,7 +878,7 @@ class FunctionMaker(object):
elif isinstance(input, (list, tuple)): elif isinstance(input, (list, tuple)):
# (r, u) -> SymbolicInput(variable=r, update=u) # (r, u) -> SymbolicInput(variable=r, update=u)
if len(input) == 2: if len(input) == 2:
return SymbolicInput(input[0], update = input[1]) return SymbolicInput(input[0], update=input[1])
else: else:
raise TypeError("Expected two elements in the list or tuple.", input) raise TypeError("Expected two elements in the list or tuple.", input)
else: else:
...@@ -899,7 +901,7 @@ class FunctionMaker(object): ...@@ -899,7 +901,7 @@ class FunctionMaker(object):
stacklevel=2) stacklevel=2)
return self.fgraph return self.fgraph
def env_setter(self,value): def env_setter(self, value):
warnings.warn("FunctionMaker.env is deprecated, it has been renamed 'fgraph'", warnings.warn("FunctionMaker.env is deprecated, it has been renamed 'fgraph'",
stacklevel=2) stacklevel=2)
self.fgraph = value self.fgraph = value
...@@ -911,7 +913,6 @@ class FunctionMaker(object): ...@@ -911,7 +913,6 @@ class FunctionMaker(object):
env = property(env_getter, env_setter, env_deleter) env = property(env_getter, env_setter, env_deleter)
@staticmethod @staticmethod
def wrap_out(output): def wrap_out(output):
if isinstance(output, SymbolicOutput): if isinstance(output, SymbolicOutput):
...@@ -922,7 +923,7 @@ class FunctionMaker(object): ...@@ -922,7 +923,7 @@ class FunctionMaker(object):
raise TypeError("Unknown output type: %s (%s)", type(output), output) raise TypeError("Unknown output type: %s (%s)", type(output), output)
def __init__(self, inputs, outputs, def __init__(self, inputs, outputs,
mode = None, accept_inplace = False, function_builder = Function, mode=None, accept_inplace=False, function_builder=Function,
profile=None, on_unused_input=None): profile=None, on_unused_input=None):
""" """
:type inputs: a list of SymbolicInput instances :type inputs: a list of SymbolicInput instances
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论