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

Function PyArray_Ptp

numpy/core/src/multiarray/calculation.c:271–306  ·  view source on GitHub ↗

NUMPY_API * Ptp */

Source from the content-addressed store, hash-verified

269 * Ptp
270 */
271NPY_NO_EXPORT PyObject *
272PyArray_Ptp(PyArrayObject *ap, int axis, PyArrayObject *out)
273{
274 PyArrayObject *arr;
275 PyObject *ret;
276 PyObject *obj1 = NULL, *obj2 = NULL;
277
278 arr=(PyArrayObject *)PyArray_CheckAxis(ap, &axis, 0);
279 if (arr == NULL) {
280 return NULL;
281 }
282 obj1 = PyArray_Max(arr, axis, out);
283 if (obj1 == NULL) {
284 goto fail;
285 }
286 obj2 = PyArray_Min(arr, axis, NULL);
287 if (obj2 == NULL) {
288 goto fail;
289 }
290 Py_DECREF(arr);
291 if (out) {
292 ret = PyObject_CallFunction(n_ops.subtract, "OOO", out, obj2, out);
293 }
294 else {
295 ret = PyNumber_Subtract(obj1, obj2);
296 }
297 Py_DECREF(obj1);
298 Py_DECREF(obj2);
299 return ret;
300
301 fail:
302 Py_XDECREF(arr);
303 Py_XDECREF(obj1);
304 Py_XDECREF(obj2);
305 return NULL;
306}
307
308
309

Callers

nothing calls this directly

Calls 3

PyArray_CheckAxisFunction · 0.85
PyArray_MaxFunction · 0.85
PyArray_MinFunction · 0.85

Tested by

no test coverage detected