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

Function PyArray_TupleFromItems

numpy/core/src/multiarray/common.h:314–333  ·  view source on GitHub ↗

* Simple helper to create a tuple from an array of items. The `make_null_none` * flag means that NULL entries are replaced with None, which is occasionally * useful. */

Source from the content-addressed store, hash-verified

312 * useful.
313 */
314static inline PyObject *
315PyArray_TupleFromItems(int n, PyObject *const *items, int make_null_none)
316{
317 PyObject *tuple = PyTuple_New(n);
318 if (tuple == NULL) {
319 return NULL;
320 }
321 for (int i = 0; i < n; i ++) {
322 PyObject *tmp;
323 if (!make_null_none || items[i] != NULL) {
324 tmp = items[i];
325 }
326 else {
327 tmp = Py_None;
328 }
329 Py_INCREF(tmp);
330 PyTuple_SET_ITEM(tuple, i, tmp);
331 }
332 return tuple;
333}
334
335/*
336 * Returns 0 if the array has rank 0, -1 otherwise. Prints a deprecation

Callers 10

boundarraymethod_reprFunction · 0.85
PyUFunc_AddWrappingLoopFunction · 0.85
sfloat_add_loopFunction · 0.85
ufunc_generic_fastcallFunction · 0.85
PyUFunc_AddLoopFromSpecFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected