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

Function npyiter_prepare_operands

numpy/core/src/multiarray/nditer_constr.c:1189–1272  ·  view source on GitHub ↗

* Process all the operands, copying new references so further processing * can replace the arrays if copying is necessary. */

Source from the content-addressed store, hash-verified

1187 * can replace the arrays if copying is necessary.
1188 */
1189static int
1190npyiter_prepare_operands(int nop, PyArrayObject **op_in,
1191 PyArrayObject **op,
1192 char **op_dataptr,
1193 PyArray_Descr **op_request_dtypes,
1194 PyArray_Descr **op_dtype,
1195 npy_uint32 flags,
1196 npy_uint32 *op_flags, npyiter_opitflags *op_itflags,
1197 npy_int8 *out_maskop)
1198{
1199 int iop, i;
1200 npy_int8 maskop = -1;
1201 int any_writemasked_ops = 0;
1202
1203 /*
1204 * Here we just prepare the provided operands.
1205 */
1206 for (iop = 0; iop < nop; ++iop) {
1207 op[iop] = op_in[iop];
1208 Py_XINCREF(op[iop]);
1209 op_dtype[iop] = NULL;
1210
1211 /* Check the readonly/writeonly flags, and fill in op_itflags */
1212 if (!npyiter_check_per_op_flags(op_flags[iop], &op_itflags[iop])) {
1213 goto fail_iop;
1214 }
1215
1216 /* Extract the operand which is for masked iteration */
1217 if ((op_flags[iop] & NPY_ITER_ARRAYMASK) != 0) {
1218 if (maskop != -1) {
1219 PyErr_SetString(PyExc_ValueError,
1220 "Only one iterator operand may receive an "
1221 "ARRAYMASK flag");
1222 goto fail_iop;
1223 }
1224
1225 maskop = iop;
1226 *out_maskop = iop;
1227 }
1228
1229 if (op_flags[iop] & NPY_ITER_WRITEMASKED) {
1230 any_writemasked_ops = 1;
1231 }
1232
1233 /*
1234 * Prepare the operand. This produces an op_dtype[iop] reference
1235 * on success.
1236 */
1237 if (!npyiter_prepare_one_operand(&op[iop],
1238 &op_dataptr[iop],
1239 op_request_dtypes ? op_request_dtypes[iop] : NULL,
1240 &op_dtype[iop],
1241 flags,
1242 op_flags[iop], &op_itflags[iop])) {
1243 goto fail_iop;
1244 }
1245 }
1246

Callers 1

NpyIter_AdvancedNewFunction · 0.85

Calls 2

Tested by

no test coverage detected