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

Function PyArray_IntpFromIndexSequence

numpy/core/src/multiarray/conversion_utils.c:1091–1109  ·  view source on GitHub ↗

* Reads values from a sequence of integers and stores them into an array. * * @param seq A sequence created using `PySequence_Fast`. * @param vals Array used to store dimensions (must be large enough to * hold `maxvals` values). * @param max_vals Maximum number of dimensions that can be written into `vals`. * @return Number of dimensions or -1 if an

Source from the content-addressed store, hash-verified

1089 * for the number of values.
1090 */
1091NPY_NO_EXPORT npy_intp
1092PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals)
1093{
1094 /*
1095 * First of all, check if sequence is a scalar integer or if it can be
1096 * "casted" into a scalar.
1097 */
1098 Py_ssize_t nd = PySequence_Fast_GET_SIZE(seq);
1099 PyObject *op;
1100 for (Py_ssize_t i = 0; i < PyArray_MIN(nd, maxvals); i++) {
1101 op = PySequence_Fast_GET_ITEM(seq, i);
1102
1103 vals[i] = dimension_from_scalar(op);
1104 if (error_converting(vals[i])) {
1105 return -1;
1106 }
1107 }
1108 return nd;
1109}
1110
1111/*NUMPY_API
1112 * PyArray_IntpFromSequence

Callers 2

PyArray_IntpConverterFunction · 0.85
PyArray_IntpFromSequenceFunction · 0.85

Calls 1

dimension_from_scalarFunction · 0.85

Tested by

no test coverage detected