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

Function NpyIter_GetShape

numpy/core/src/multiarray/nditer_api.c:980–1011  ·  view source on GitHub ↗

NUMPY_API * Gets the broadcast shape if a multi-index is being tracked by the iterator, * otherwise gets the shape of the iteration as Fortran-order * (fastest-changing index first). * * The reason Fortran-order is returned when a multi-index * is not enabled is that this is providing a direct view into how * the iterator traverses the n-dimensional space. The iterator organizes * its memo

Source from the content-addressed store, hash-verified

978 * Returns NPY_SUCCEED or NPY_FAIL.
979 */
980NPY_NO_EXPORT int
981NpyIter_GetShape(NpyIter *iter, npy_intp *outshape)
982{
983 npy_uint32 itflags = NIT_ITFLAGS(iter);
984 int ndim = NIT_NDIM(iter);
985 int nop = NIT_NOP(iter);
986
987 int idim, sizeof_axisdata;
988 NpyIter_AxisData *axisdata;
989 npy_int8 *perm;
990
991 axisdata = NIT_AXISDATA(iter);
992 sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop);
993
994 if (itflags&NPY_ITFLAG_HASMULTIINDEX) {
995 perm = NIT_PERM(iter);
996 for(idim = 0; idim < ndim; ++idim) {
997 int axis = npyiter_undo_iter_axis_perm(idim, ndim, perm, NULL);
998 outshape[axis] = NAD_SHAPE(axisdata);
999
1000 NIT_ADVANCE_AXISDATA(axisdata, 1);
1001 }
1002 }
1003 else {
1004 for(idim = 0; idim < ndim; ++idim) {
1005 outshape[idim] = NAD_SHAPE(axisdata);
1006 NIT_ADVANCE_AXISDATA(axisdata, 1);
1007 }
1008 }
1009
1010 return NPY_SUCCEED;
1011}
1012
1013/*NUMPY_API
1014 * Builds a set of strides which are the same as the strides of an

Callers 2

npyiter_shape_getFunction · 0.85
arr_unravel_indexFunction · 0.85

Calls 1

Tested by

no test coverage detected