提交 cf7a54db authored 作者: John Salvatier's avatar John Salvatier

fixed up uses of string interpolation in code generation

上级 55179c3c
......@@ -20,24 +20,24 @@ def compile_cutils():
complex_types = ['npy_'+t for t in ['complex32', 'complex64', 'complex128', 'complex160', 'complex192', 'complex512'] ]
inplace_map_template = """
#if defined(%(typen))
static void %(type)_inplace_add(PyArrayMapIterObject *mit, PyArrayIterObject *it)
{{
#if defined(%(typen)s)
static void %(type)s_inplace_add(PyArrayMapIterObject *mit, PyArrayIterObject *it)
{
int index = mit->size;
while (index--) {{
%(op)
while (index--) {
%(op)s
PyArray_MapIterNext(mit);
PyArray_ITER_NEXT(it);
}}
}}
}
}
#endif
"""
floatadd = "((%(type)*)mit->dataptr)[0] = ((%(type)*)mit->dataptr)[0] + ((%(type)*)it->dataptr)[0];"
floatadd = "((%(type)s*)mit->dataptr)[0] = ((%(type)s*)mit->dataptr)[0] + ((%(type)s*)it->dataptr)[0];"
complexadd = """
((%(type)*)mit->dataptr)[0].real = ((%(type)*)mit->dataptr)[0].real + ((%(type)*)it->dataptr)[0].real;
((%(type)*)mit->dataptr)[0].imag = ((%(type)*)mit->dataptr)[0].imag + ((%(type)*)it->dataptr)[0].imag;
((%(type)s*)mit->dataptr)[0].real = ((%(type)s*)mit->dataptr)[0].real + ((%(type)s*)it->dataptr)[0].real;
((%(type)s*)mit->dataptr)[0].imag = ((%(type)s*)mit->dataptr)[0].imag + ((%(type)s*)it->dataptr)[0].imag;
"""
......@@ -46,8 +46,8 @@ def compile_cutils():
fn_array = ("inplace_map_binop addition_funcs[] = {" +
''.join(["""
#if defined(%(typen))
%(type)_inplace_add,
#if defined(%(typen)s)
%(type)s_inplace_add,
#endif
""" % {'type' : t, 'typen' : t.upper()} for t in types+complex_types]) +
"""NULL};
......@@ -55,8 +55,8 @@ def compile_cutils():
type_number_array = ("int type_numbers[] = {" +
''.join(["""
#if defined(%(typen))
%(typen),
#if defined(%(typen)s)
%(typen)s,
#endif
""" % {'type' : t, 'typen' : t.upper()} for t in types+complex_types]) +
"-1000};")
......@@ -242,6 +242,7 @@ fail:
} //extern C
"""
import cmodule
loc = os.path.join(config.compiledir, 'cutils_ext')
if not os.path.exists(loc):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论