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