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

Function array_trace

numpy/core/src/multiarray/methods.c:2564–2596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2562
2563
2564static PyObject *
2565array_trace(PyArrayObject *self,
2566 PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
2567{
2568 int axis1 = 0, axis2 = 1, offset = 0;
2569 PyArray_Descr *dtype = NULL;
2570 PyArrayObject *out = NULL;
2571 int rtype;
2572 NPY_PREPARE_ARGPARSER;
2573
2574 if (npy_parse_arguments("trace", args, len_args, kwnames,
2575 "|offset", &PyArray_PythonPyIntFromInt, &offset,
2576 "|axis1", &PyArray_PythonPyIntFromInt, &axis1,
2577 "|axis2", &PyArray_PythonPyIntFromInt, &axis2,
2578 "|dtype", &PyArray_DescrConverter2, &dtype,
2579 "|out", &PyArray_OutputConverter, &out,
2580 NULL, NULL, NULL) < 0) {
2581 Py_XDECREF(dtype);
2582 return NULL;
2583 }
2584
2585 rtype = _CHKTYPENUM(dtype);
2586 Py_XDECREF(dtype);
2587 PyObject *ret = PyArray_Trace(self, offset, axis1, axis2, rtype, out);
2588
2589 /* this matches the unpacking behavior of ufuncs */
2590 if (out == NULL) {
2591 return PyArray_Return((PyArrayObject *)ret);
2592 }
2593 else {
2594 return ret;
2595 }
2596}
2597
2598#undef _CHKTYPENUM
2599

Callers

nothing calls this directly

Calls 2

PyArray_TraceFunction · 0.85
PyArray_ReturnFunction · 0.85

Tested by

no test coverage detected