提交 15b8c753 authored 作者: Chinnadhurai Sankar's avatar Chinnadhurai Sankar

fix pep-8 errors in gof

上级 ad6a0499
......@@ -18,8 +18,8 @@ class CallCache(object):
def persist(self, filename=None):
"""
Cache "filename" as a pickle file
"""
Cache "filename" as a pickle file
"""
if filename is None:
filename = self.filename
with open(filename, 'w') as f:
......@@ -27,16 +27,16 @@ class CallCache(object):
def call(self, fn, args=(), key=None):
"""
Retrieve item from the cache(if available)
based on a key
Parameters
------------
key
parameter to retrieve cache item
fn,args
key to retrieve if "key" is None
"""
Retrieve item from the cache(if available)
based on a key
Parameters
------------
key
parameter to retrieve cache item
fn,args
key to retrieve if "key" is None
"""
if key is None:
key = (fn, tuple(args))
if key not in self.cache:
......
......@@ -115,14 +115,12 @@ def failure_code(sub):
def failure_code_init(sub):
"""
Code for failure in the struct init.
Parameters:
--------------
sub
Dictionary used to template the struct.
* failure_var -> must contain a variable name to use for
the failure code.
"""
return '''{
if (!PyErr_Occurred()) {
......@@ -137,8 +135,8 @@ def failure_code_init(sub):
def code_gen(blocks):
"""
From a list of L{CodeBlock} instances, returns a string
that executes them all in sequence.
that executes them all in sequence.
Eg for C{(decl1, task1,
cleanup1)} and C{(decl2, task2, cleanup2)} the returned string
will be of the form:
......@@ -156,7 +154,7 @@ def code_gen(blocks):
Parameters:
----------------
blocks
blocks
List of CodeBlock instances such that
* declarations, behavior and cleanup are in the run()
method of the struct
......@@ -895,7 +893,6 @@ class CLinker(link.Linker):
"""
Returns a list of support code strings that are needed by
one or more Variables or Ops.
The support code from Variables is added before the support code from Ops.This might contain duplicates.
"""
ret = []
......@@ -1172,10 +1169,8 @@ class CLinker(link.Linker):
be allocated.
storage_map: dict that map variables to storages.
This is used when you need to customize the storage of
this thunk.
keep_lock
WRITEME
this thunk.keep_lock
WRITEME
Returns: thunk, input_storage, output_storage
The return values can be used as follows:
......@@ -1845,11 +1840,10 @@ def _default_checker(x, y):
"""
Default checker for DualLinker. This checks that the
variables contain the same data using ==.
Parameters
-------------
x,y
the variables to compare data
x,y
the variables to compare data
"""
if x[0] != y[0]:
raise Exception("Output mismatch.",
......
......@@ -1474,10 +1474,9 @@ class ModuleCache(object):
def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG,
ignore_if_missing=False):
"""
On NFS filesystems, it is impossible to delete a directory with open
files in it.
files in it.
So instead, some commands in this file will respond to a
failed rmtree() by touching a 'delete.me' file. This file is a message
......@@ -1485,13 +1484,13 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG,
Paramters
----------
parent
Root node to start deleting from
Root node to start deleting from
ignore_nocleanup
Delete the tree if flag is TRUE
Delete the tree if flag is TRUE
level
Python Logging level. Set to "DEBUG" by default
Python Logging level. Set to "DEBUG" by default
ignore_if_missing
If set to True, just return without any issue if parent is NULL
If set to True, just return without any issue if parent is NULL
"""
if ignore_if_missing and not os.path.exists(parent):
return
......
......@@ -708,7 +708,7 @@ def variables_and_orphans(i, o):
i : list
Input L{Variable}s.
o : list
Output L{Variable}s.
Output L{Variable}s.
"""
def expand(r):
......@@ -775,7 +775,7 @@ def variables(i, o):
def orphans(i, o):
"""
Extracts list of variables within input and output nodes ( via dfs t ravesal) and returns the "orphans" among them
Parameters
----------
i : list
......@@ -1225,7 +1225,7 @@ def op_as_string(i, op,
leaf_formatter=default_leaf_formatter,
node_formatter=default_node_formatter):
"""
Op to return a string representation of the subgraph
Op to return a string representation of the subgraph
between i and o
"""
strs = as_string(i, op.inputs, leaf_formatter, node_formatter)
......
......@@ -54,8 +54,7 @@ def thunk_hook(type, value, trace):
"""
This function is meant to replace excepthook and do some
special work if the exception value has a __thunk_trace__
field.
field.
In that case, it retrieves the field, which should
contain a trace as returned by L{traceback.extract_stack},
and prints it out on L{stderr}.
......@@ -64,7 +63,7 @@ def thunk_hook(type, value, trace):
Parameters
------------
type
Exception class
Exception class
value
Exception instance
trace
......@@ -617,7 +616,7 @@ def map_storage(fgraph, order, input_storage, output_storage, storage_map=None):
def streamline(fgraph, thunks, order, post_thunk_old_storage=None,
no_recycling=None, nice_errors=True):
"""
WRITEME
WRITEME
Parameters
----------
......@@ -714,7 +713,6 @@ class LocalLinker(Linker):
def gc_helper(node_list):
"""
Return the set of Variable instances which are computed by node_list.
Parameters
----------
node_list
......@@ -790,7 +788,7 @@ class PerformLinker(LocalLinker):
def make_all(self, input_storage=None, output_storage=None, storage_map=None):
"""
Returns Function to run all nodes, list of input containers, list of outputs
Returns Function to run all nodes, list of input containers, list of outputs
Parameters
----------
......
......@@ -792,8 +792,8 @@ class Op(utils.object2, PureOp, CLinkerOp):
def _props(self):
"""
Tuple of properties of all attributes
"""
Tuple of properties of all attributes
"""
return tuple(getattr(self, a) for a in self.__props__)
def _props_dict(self):
......@@ -927,7 +927,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
def make_thunk(self, node, storage_map, compute_map, no_recycling):
"""
This function must return a thunk, that is a zero-arguments
This function must return a thunk, that is a zero-arguments
function that encapsulates the computation to be performed
by this op on the arguments of the node.
......@@ -981,9 +981,8 @@ class Op(utils.object2, PureOp, CLinkerOp):
def make_node(self, *inputs):
"""
Create a "apply" nodes for the inputs in that order.
"""
Create a "apply" nodes for the inputs in that order.
"""
if not hasattr(self, 'itypes'):
raise NotImplementedError("You can either define itypes and otypes,\
or implement make_node")
......@@ -1068,7 +1067,7 @@ def debug_error_message(msg):
def debug_assert(condition, msg=None):
"""
Customized assert with options to ignore the assert
Customized assert with options to ignore the assert
with just a warning
"""
if msg is None:
......@@ -1179,8 +1178,8 @@ class OpenMPOp(Op):
def c_compile_args(self):
"""
Return the compilation arg "fopenmp" if openMP is supported
"""
Return the compilation arg "fopenmp" if openMP is supported
"""
self.update_self_openmp()
if self.openmp:
return ['-fopenmp']
......@@ -1188,9 +1187,8 @@ class OpenMPOp(Op):
def c_headers(self):
"""
Return the header file name "omp.h" if openMP is supported
"""
Return the header file name "omp.h" if openMP is supported
"""
self.update_self_openmp()
if self.openmp:
return ["omp.h"]
......@@ -1199,8 +1197,8 @@ class OpenMPOp(Op):
@staticmethod
def test_gxx_support():
"""
Check if openMP is supported
"""
Check if openMP is supported
"""
code = """
#include <omp.h>
int main( int argc, const char* argv[] )
......@@ -1418,7 +1416,7 @@ class COp(Op):
def c_init_code(self):
"""
Get the code section for init_code
Get the code section for init_code
"""
if 'init_code' in self.code_sections:
return [self.code_sections['init_code']]
......@@ -1588,8 +1586,8 @@ class COp(Op):
def c_code_cleanup(self, node, name, inputs, outputs, sub):
"""
Stitches all the macros and "code_cleanup" together
"""
Stitches all the macros and "code_cleanup" together
"""
if 'code_cleanup' in self.code_sections:
op_code = self.code_sections['code_cleanup']
......
......@@ -115,19 +115,19 @@ class Bookkeeper(Feature):
def on_attach(self, fgraph):
"""
Called by FunctionGraph.attach_feature, the method that attaches
Called by FunctionGraph.attach_feature, the method that attaches
the feature to the FunctionGraph. Since this is called after the
FunctionGraph is initially populated, this is where you should
run checks on the initial contents of the FunctionGraph.
"""
"""
for node in graph.io_toposort(fgraph.inputs, fgraph.outputs):
self.on_import(fgraph, node, "on_attach")
def on_detach(self, fgraph):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
for node in graph.io_toposort(fgraph.inputs, fgraph.outputs):
self.on_prune(fgraph, node, 'Bookkeeper.detach')
......@@ -189,9 +189,9 @@ class History(Feature):
def on_detach(self, fgraph):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
del fgraph.checkpoint
del fgraph.revert
del self.history[fgraph]
......@@ -238,18 +238,18 @@ class Validator(Feature):
def on_detach(self, fgraph):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
del fgraph.validate
"""
del fgraph.validate
del fgraph.consistent
def validate_(self, fgraph):
"""
If the caller is replace_all_validate, just raise the
If the caller is replace_all_validate, just raise the
exception. replace_all_validate will print out the
verbose output. Or it has to be done here before raise.
"""
"""
t0 = time.time()
try:
ret = fgraph.execute_callbacks('validate')
......@@ -313,9 +313,9 @@ class ReplaceValidate(History, Validator):
def on_detach(self, fgraph):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
History.on_detach(self, fgraph)
Validator.on_detach(self, fgraph)
del self._nodes_removed
......@@ -440,9 +440,9 @@ class NodeFinder(Bookkeeper):
def on_detach(self, fgraph):
"""
Should remove any dynamically added functionality
Should remove any dynamically added functionality
that it installed into the function_graph
"""
"""
if self.fgraph is not fgraph:
raise Exception("This NodeFinder instance was not attached to the"
" provided fgraph.")
......@@ -493,9 +493,9 @@ class PrintListener(Feature):
def on_detach(self, fgraph):
"""
Should remove any dynamically added functionality
that it installed into the function_graph
"""
Should remove any dynamically added functionality
that it installed into the function_graph
"""
if self.active:
print("-- detaching from: ", fgraph)
......
......@@ -4,7 +4,7 @@ can be "unified" if there exists an assignment to all unification variables
such that the two expressions are equal.
For instance, [5, A, B] and [A, C, 9] can be unified if A=C=5 and B=9,
yielding [5, 5, 9].
yielding [5, 5, 9].
[5, [A, B]] and [A, [1, 2]] cannot be unified because there is no value for A
that satisfies the constraints. That's useful for pattern matching.
......@@ -135,8 +135,6 @@ class Unification:
"""
This class represents a possible unification of a group of variables
with each other or with tangible values.
Parameters
----------
inplace : bool
......
......@@ -728,8 +728,8 @@ class VM_Linker(link.LocalLinker):
def accept(self, fgraph, no_recycling=None):
"""
Check if fgraph is the first FunctionGraph that has ever been
associated to self, else, create a new VM_Linker
Check if fgraph is the first FunctionGraph that has ever been
associated to self, else, create a new VM_Linker
associated to fgraph
Parameters
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论