diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-12-27 17:44:33 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-12-27 17:44:33 +0000 |
commit | 5b6b1fe2f957e22162233878888e2e3d5454a6a9 (patch) | |
tree | 57c2e7611c1c86dc850578910af8cfe530a27f50 | |
parent | 2d761b6ac092b93cb011db524e9f230957e5ff0f (diff) | |
download | python-numpy-5b6b1fe2f957e22162233878888e2e3d5454a6a9.tar.gz python-numpy-5b6b1fe2f957e22162233878888e2e3d5454a6a9.tar.bz2 python-numpy-5b6b1fe2f957e22162233878888e2e3d5454a6a9.zip |
MAINT: Use textwrap.dedent for readability
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 9287be095..40bc1560f 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -988,13 +988,16 @@ def make_arrays(funcdict): funclist.append('%s_%s' % (tname, name)) if t.simd is not None: for vt in t.simd: - code2list.append("""\ -#ifdef HAVE_ATTRIBUTE_TARGET_{ISA} -if (NPY_CPU_SUPPORTS_{ISA}) {{ - {fname}_functions[{idx}] = {type}_{fname}_{isa}; -}} -#endif -""".format(ISA=vt.upper(), isa=vt, fname=name, type=tname, idx=k)) + code2list.append(textwrap.dedent("""\ + #ifdef HAVE_ATTRIBUTE_TARGET_{ISA} + if (NPY_CPU_SUPPORTS_{ISA}) {{ + {fname}_functions[{idx}] = {type}_{fname}_{isa}; + }} + #endif + """).format( + ISA=vt.upper(), isa=vt, + fname=name, type=tname, idx=k + )) for x in t.in_ + t.out: siglist.append('NPY_%s' % (english_upper(chartoname[x]),)) @@ -1032,10 +1035,10 @@ def make_ufuncs(funcdict): # string literal in C code. We split at endlines because textwrap.wrap # do not play well with \n docstring = '\\n\"\"'.join(docstring.split(r"\n")) - mlist.append(\ -r"""f = PyUFunc_FromFuncAndData(%s_functions, %s_data, %s_signatures, %d, - %d, %d, %s, "%s", - "%s", 0);""" % (name, name, name, + mlist.append(textwrap.dedent("""\ + f = PyUFunc_FromFuncAndData(%s_functions, %s_data, %s_signatures, %d, + %d, %d, %s, "%s", + "%s", 0);""") % (name, name, name, len(uf.type_descriptions), uf.nin, uf.nout, uf.identity, @@ -1054,23 +1057,23 @@ def make_code(funcdict, filename): code3 = make_ufuncs(funcdict) code2 = indent(code2, 4) code3 = indent(code3, 4) - code = r""" + code = textwrap.dedent(r""" -/** Warning this file is autogenerated!!! + /** Warning this file is autogenerated!!! - Please make changes to the code generator program (%s) -**/ + Please make changes to the code generator program (%s) + **/ -%s + %s -static void -InitOperators(PyObject *dictionary) { - PyObject *f; + static void + InitOperators(PyObject *dictionary) { + PyObject *f; -%s -%s -} -""" % (filename, code1, code2, code3) + %s + %s + } + """) % (filename, code1, code2, code3) return code |