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

Function PyArray_Flatten

numpy/core/src/multiarray/shape.c:958–985  ·  view source on GitHub ↗

NUMPY_API * Flatten */

Source from the content-addressed store, hash-verified

956 * Flatten
957 */
958NPY_NO_EXPORT PyObject *
959PyArray_Flatten(PyArrayObject *a, NPY_ORDER order)
960{
961 PyArrayObject *ret;
962 npy_intp size;
963
964 if (order == NPY_ANYORDER) {
965 order = PyArray_ISFORTRAN(a) ? NPY_FORTRANORDER : NPY_CORDER;
966 }
967
968 size = PyArray_SIZE(a);
969 Py_INCREF(PyArray_DESCR(a));
970 ret = (PyArrayObject *)PyArray_NewFromDescr(Py_TYPE(a),
971 PyArray_DESCR(a),
972 1, &size,
973 NULL,
974 NULL,
975 0, (PyObject *)a);
976 if (ret == NULL) {
977 return NULL;
978 }
979
980 if (PyArray_CopyAsFlat(ret, a, order) < 0) {
981 Py_DECREF(ret);
982 return NULL;
983 }
984 return (PyObject *)ret;
985}
986
987
988/*NUMPY_API

Callers 3

array_flattenFunction · 0.85
PyArray_RavelFunction · 0.85
iter_copyFunction · 0.85

Calls 3

PyArray_DESCRFunction · 0.85
PyArray_NewFromDescrFunction · 0.85
PyArray_CopyAsFlatFunction · 0.85

Tested by

no test coverage detected