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

Function array_reduce_ex

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

Source from the content-addressed store, hash-verified

1989}
1990
1991static PyObject *
1992array_reduce_ex(PyArrayObject *self, PyObject *args)
1993{
1994 int protocol;
1995 PyArray_Descr *descr = NULL;
1996
1997 if (!PyArg_ParseTuple(args, "i", &protocol)) {
1998 return NULL;
1999 }
2000
2001 descr = PyArray_DESCR(self);
2002 if ((protocol < 5) ||
2003 (!PyArray_IS_C_CONTIGUOUS((PyArrayObject*)self) &&
2004 !PyArray_IS_F_CONTIGUOUS((PyArrayObject*)self)) ||
2005 PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
2006 (PyType_IsSubtype(((PyObject*)self)->ob_type, &PyArray_Type) &&
2007 ((PyObject*)self)->ob_type != &PyArray_Type) ||
2008 descr->elsize == 0) {
2009 /* The PickleBuffer class from version 5 of the pickle protocol
2010 * can only be used for arrays backed by a contiguous data buffer.
2011 * For all other cases we fallback to the generic array_reduce
2012 * method that involves using a temporary bytes allocation. */
2013 return array_reduce_ex_regular(self, protocol);
2014 }
2015 else {
2016 return array_reduce_ex_picklebuffer(self, protocol);
2017 }
2018}
2019
2020static PyObject *
2021array_setstate(PyArrayObject *self, PyObject *args)

Callers

nothing calls this directly

Calls 3

PyArray_DESCRFunction · 0.85
array_reduce_ex_regularFunction · 0.85

Tested by

no test coverage detected