MCPcopy Index your code
hub / github.com/numpy/numpy / make_arrays

Function make_arrays

numpy/_core/code_generators/generate_umath.py:1440–1538  ·  view source on GitHub ↗
(funcdict)

Source from the content-addressed store, hash-verified

1438# 3) add function.
1439
1440def make_arrays(funcdict):
1441 # functions array contains an entry for every type implemented NULL
1442 # should be placed where PyUfunc_ style function will be filled in
1443 # later
1444 code1list = []
1445 code2list = []
1446 dispdict = {}
1447 names = sorted(funcdict.keys())
1448 for name in names:
1449 uf = funcdict[name]
1450 funclist = []
1451 datalist = []
1452 siglist = []
1453 sub = 0
1454
1455 for k, t in enumerate(uf.type_descriptions):
1456 cfunc_alias = t.cfunc_alias or name
1457 cfunc_fname = None
1458 if t.func_data is FullTypeDescr:
1459 tname = english_upper(chartoname[t.type])
1460 datalist.append('(void *)NULL')
1461 if t.out == "?":
1462 cfunc_fname = f"{tname}_{t.in_}_bool_{cfunc_alias}"
1463 else:
1464 cfunc_fname = f"{tname}_{t.in_}_{t.out}_{cfunc_alias}"
1465 elif isinstance(t.func_data, FuncNameSuffix):
1466 datalist.append('(void *)NULL')
1467 tname = english_upper(chartoname[t.type])
1468 cfunc_fname = f"{tname}_{cfunc_alias}_{t.func_data.suffix}"
1469 elif t.func_data is None:
1470 datalist.append('(void *)NULL')
1471 tname = english_upper(chartoname[t.type])
1472 cfunc_fname = f"{tname}_{cfunc_alias}"
1473 else:
1474 try:
1475 thedict = arity_lookup[uf.nin, uf.nout]
1476 except KeyError as e:
1477 raise ValueError(
1478 f"Could not handle {name}[{t.type}] "
1479 f"with nin={uf.nin}, nout={uf.nout}"
1480 ) from None
1481
1482 astype = ''
1483 if t.astype is not None:
1484 astype = f'_As_{thedict[t.astype]}'
1485 astr = f'{name}_functions[{k}] = PyUFunc_{thedict[t.type]}{astype};'
1486 code2list.append(astr)
1487 if t.type == 'O':
1488 astr = f'{name}_data[{k}] = (void *) {t.func_data};'
1489 code2list.append(astr)
1490 datalist.append('(void *)NULL')
1491 elif t.type == 'P':
1492 datalist.append(f'(void *)"{t.func_data}"')
1493 else:
1494 astr = f'{name}_data[{k}] = (void *) {t.func_data};'
1495 code2list.append(astr)
1496 datalist.append('(void *)NULL')
1497 #datalist.append('(void *)%s' % t.func_data)

Callers 1

make_codeFunction · 0.85

Calls 4

joinMethod · 0.80
itemsMethod · 0.80
english_upperFunction · 0.70
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…