MCPcopy Create free account
hub / github.com/numpy/numpy / make_arrays

Function make_arrays

numpy/core/code_generators/generate_umath.py:1176–1272  ·  view source on GitHub ↗
(funcdict)

Source from the content-addressed store, hash-verified

1174# 3) add function.
1175
1176def make_arrays(funcdict):
1177 # functions array contains an entry for every type implemented NULL
1178 # should be placed where PyUfunc_ style function will be filled in
1179 # later
1180 code1list = []
1181 code2list = []
1182 dispdict = {}
1183 names = sorted(funcdict.keys())
1184 for name in names:
1185 uf = funcdict[name]
1186 funclist = []
1187 datalist = []
1188 siglist = []
1189 k = 0
1190 sub = 0
1191
1192 for t in uf.type_descriptions:
1193 cfunc_alias = t.cfunc_alias if t.cfunc_alias else name
1194 cfunc_fname = None
1195 if t.func_data is FullTypeDescr:
1196 tname = english_upper(chartoname[t.type])
1197 datalist.append('(void *)NULL')
1198 if t.out == "?":
1199 cfunc_fname = f"{tname}_{t.in_}_bool_{cfunc_alias}"
1200 else:
1201 cfunc_fname = f"{tname}_{t.in_}_{t.out}_{cfunc_alias}"
1202 elif isinstance(t.func_data, FuncNameSuffix):
1203 datalist.append('(void *)NULL')
1204 tname = english_upper(chartoname[t.type])
1205 cfunc_fname = f"{tname}_{cfunc_alias}_{t.func_data.suffix}"
1206 elif t.func_data is None:
1207 datalist.append('(void *)NULL')
1208 tname = english_upper(chartoname[t.type])
1209 cfunc_fname = f"{tname}_{cfunc_alias}"
1210 else:
1211 try:
1212 thedict = arity_lookup[uf.nin, uf.nout]
1213 except KeyError as e:
1214 raise ValueError(
1215 f"Could not handle {name}[{t.type}] "
1216 f"with nin={uf.nin}, nout={uf.nout}"
1217 ) from None
1218
1219 astype = ''
1220 if not t.astype is None:
1221 astype = '_As_%s' % thedict[t.astype]
1222 astr = ('%s_functions[%d] = PyUFunc_%s%s;' %
1223 (name, k, thedict[t.type], astype))
1224 code2list.append(astr)
1225 if t.type == 'O':
1226 astr = ('%s_data[%d] = (void *) %s;' %
1227 (name, k, t.func_data))
1228 code2list.append(astr)
1229 datalist.append('(void *)NULL')
1230 elif t.type == 'P':
1231 datalist.append('(void *)"%s"' % t.func_data)
1232 else:
1233 astr = ('%s_data[%d] = (void *) %s;' %

Callers 1

make_codeFunction · 0.85

Calls 3

keysMethod · 0.80
english_upperFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected