8000 Merge pull request #10509 from eric-wieser/generate_umath-format-string · numpy/numpy@2854d50 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2854d50

Browse files
authored
Merge pull request #10509 from eric-wieser/generate_umath-format-string
MAINT: Use new-style format strings for clarity
2 parents d1c66d0 + e3c7433 commit 2854d50

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

numpy/core/code_generators/generate_umath.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,14 +1040,16 @@ def make_ufuncs(funcdict):
10401040
# string literal in C code. We split at endlines because textwrap.wrap
10411041
# do not play well with \n
10421042
docstring = '\\n\"\"'.join(docstring.split(r"\n"))
1043-
mlist.append(textwrap.dedent("""\
1044-
f = PyUFunc_FromFuncAndData(%s_functions, %s_data, %s_signatures, %d,
1045-
%d, %d, %s, "%s",
1046-
"%s", 0);""") % (name, name, name,
1047-
len(uf.type_descriptions),
1048-
uf.nin, uf.nout,
1049-
uf.identity,
1050-
name, docstring))
1043+
fmt = textwrap.dedent("""\
1044+
f = PyUFunc_FromFuncAndData(
1045+
{name}_functions, {name}_data, {name}_signatures, {nloops},
1046+
{nin}, {nout}, {identity}, "{name}",
1047+
"{doc}", 0
1048+
);""")
1049+
mlist.append(fmt.format(
1050+
name=name, nloops=len(uf.type_descriptions),
1051+
nin=uf.nin, nout=uf.nout, identity=uf.identity, doc=docstring
1052+
))
10511053
if uf.typereso is not None:
10521054
mlist.append(
10531055
r"((PyUFuncObject *)f)->type_resolver = &%s;" % uf.typereso)

0 commit comments

Comments
 (0)
0