提交 a2941943 authored 作者: Iban Harlouchet's avatar Iban Harlouchet 提交者: Frederic

flake8 of theano/gof/op.py; 3 E left

上级 d9166080
......@@ -4,14 +4,6 @@ The `Op` class is the base interface for all operations
compatible with `gof`'s :doc:`graph` routines.
"""
__authors__ = "theano-dev"
__copyright__ = "(c) 2010, Universite de Montreal"
__license__ = "3-clause BSD License"
__contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__ = "restructuredtext en"
import inspect
import logging
import numpy
......@@ -32,6 +24,13 @@ from theano.gof import utils
from theano.gof.cmodule import GCC_compiler
from theano.gof.fg import FunctionGraph
__authors__ = "theano-dev"
__copyright__ = "(c) 2010, Universite de Montreal"
__license__ = "3-clause BSD License"
__contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__ = "restructuredtext en"
class CLinkerObject(object):
"""Standard elements of an Op or Type used with the CLinker
......@@ -224,8 +223,7 @@ class CLinkerOp(CLinkerObject):
- `MethodNotDefined`: the subclass does not override this method
"""
raise utils.MethodNotDefined('%s.c_code' \
% self.__class__.__name__)
raise utils.MethodNotDefined('%s.c_code' % self.__class__.__name__)
def c_code_cache_version_apply(self, node):
"""Return a tuple of integers indicating the version of this Op.
......@@ -278,8 +276,8 @@ class CLinkerOp(CLinkerObject):
:Exceptions:
- `MethodNotDefined`: the subclass does not override this method
"""
raise utils.MethodNotDefined('%s.c_code_cleanup' \
% self.__class__.__name__)
raise utils.MethodNotDefined('%s.c_code_cleanup' %
self.__class__.__name__)
def c_support_code_apply(self, node, name):
"""Optional: Return utility code for use by an `Op` that will be
......@@ -763,6 +761,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
return r
else:
ctx_val = node.context_type.filter(ctx)
def rval(p=p, i=node_input_storage, o=node_output_storage, n=node,
ctx=ctx_val):
r = p(n, [x[0] for x in i], o, ctx)
......@@ -1141,9 +1140,9 @@ class COp(Op):
n = 1
while n < len(split):
if split[n] == 'APPLY':
self.code_sections['support_code_apply'] = split[n+1]
self.code_sections['support_code_apply'] = split[n + 1]
elif split[n] == 'SUPPORT':
self.code_sections['support_code'] = split[n+1]
self.code_sections['support_code'] = split[n + 1]
n += 2
continue
......@@ -1164,7 +1163,7 @@ class COp(Op):
(self.func_files[i], split[n]))
if split[n] not in self.code_sections:
self.code_sections[split[n]] = ""
self.code_sections[split[n]] += split[n+1]
self.code_sections[split[n]] += split[n + 1]
n += 2
else:
......@@ -1267,8 +1266,8 @@ class COp(Op):
def get_sub_macros(self, sub):
define_macros = []
undef_macros = []
define_macros.append("#define FAIL %s" %
(self._lquote_macro(sub['fail']),))
define_macros.append("#define FAIL %s" % (
self._lquote_macro(sub['fail']),))
undef_macros.append("#undef FAIL")
if 'context' in sub:
define_macros.append("#define CONTEXT %s" % (sub['context'],))
......@@ -1305,25 +1304,24 @@ class COp(Op):
def c_code(self, node, name, inp, out, sub):
if self.func_name is not None:
assert 'code' not in self.code_sections
func_name = self.func_name
func_args = self.format_c_function_args(inp, out)
fail = sub['fail']
define_macros, undef_macros = self.get_c_macros(node, name,
check_input=False)
# Generate the C code
return """
%(define_macros)s
{
%(define_macros)s
{
if (%(func_name)s(%(func_args)s) != 0) {
%(fail)s
}
}
%(undef_macros)s
""" % dict(func_name=self.func_name, fail=sub['fail'],
}
%(undef_macros)s
""" % dict(func_name=self.func_name,
fail=sub['fail'],
func_args=self.format_c_function_args(inp, out),
define_macros=define_macros, undef_macros=undef_macros)
define_macros=define_macros,
undef_macros=undef_macros)
else:
if 'code' in self.code_sections:
op_code = self.code_sections['code']
......
......@@ -225,7 +225,6 @@ whitelist_flake8 = [
"sparse/sandbox/sp.py",
"gof/unify.py",
"gof/__init__.py",
"gof/op.py",
"gof/tests/test_cmodule.py",
"gof/tests/test_destroyhandler.py",
"gof/tests/test_opt.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论