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

Function PyArray_ElementStrides

numpy/core/src/multiarray/arrayobject.c:1079–1103  ·  view source on GitHub ↗

NUMPY_API */

Source from the content-addressed store, hash-verified

1077/*NUMPY_API
1078 */
1079NPY_NO_EXPORT int
1080PyArray_ElementStrides(PyObject *obj)
1081{
1082 PyArrayObject *arr;
1083 int itemsize;
1084 int i, ndim;
1085 npy_intp *strides;
1086
1087 if (!PyArray_Check(obj)) {
1088 return 0;
1089 }
1090
1091 arr = (PyArrayObject *)obj;
1092
1093 itemsize = PyArray_ITEMSIZE(arr);
1094 ndim = PyArray_NDIM(arr);
1095 strides = PyArray_STRIDES(arr);
1096
1097 for (i = 0; i < ndim; i++) {
1098 if ((strides[i] % itemsize) != 0) {
1099 return 0;
1100 }
1101 }
1102 return 1;
1103}
1104
1105/*
1106 * This routine checks to see if newstrides (of length nd) will not

Callers 1

PyArray_CheckFromAny_intFunction · 0.85

Calls 3

PyArray_ITEMSIZEFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_STRIDESFunction · 0.85

Tested by

no test coverage detected