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

Function PyArrayMethod_GetMaskedStridedLoop

numpy/core/src/multiarray/array_method.c:913–945  ·  view source on GitHub ↗

* Fetches a strided-loop function that supports a boolean mask as additional * (last) operand to the strided-loop. It is otherwise largely identical to * the `get_strided_loop` method which it wraps. * This is the core implementation for the ufunc `where=...` keyword argument. * * NOTE: This function does not support `move_references` or inner dimensions. */

Source from the content-addressed store, hash-verified

911 * NOTE: This function does not support `move_references` or inner dimensions.
912 */
913NPY_NO_EXPORT int
914PyArrayMethod_GetMaskedStridedLoop(
915 PyArrayMethod_Context *context,
916 int aligned, npy_intp *fixed_strides,
917 PyArrayMethod_StridedLoop **out_loop,
918 NpyAuxData **out_transferdata,
919 NPY_ARRAYMETHOD_FLAGS *flags)
920{
921 _masked_stridedloop_data *data;
922 int nargs = context->method->nin + context->method->nout;
923
924 /* Add working memory for the data pointers, to modify them in-place */
925 data = PyMem_Malloc(sizeof(_masked_stridedloop_data) +
926 sizeof(char *) * nargs);
927 if (data == NULL) {
928 PyErr_NoMemory();
929 return -1;
930 }
931 data->base.free = _masked_stridedloop_data_free;
932 data->base.clone = NULL; /* not currently used */
933 data->unmasked_stridedloop = NULL;
934 data->nargs = nargs;
935
936 if (context->method->get_strided_loop(context,
937 aligned, 0, fixed_strides,
938 &data->unmasked_stridedloop, &data->unmasked_auxdata, flags) < 0) {
939 PyMem_Free(data);
940 return -1;
941 }
942 *out_transferdata = (NpyAuxData *)data;
943 *out_loop = generic_masked_strided_loop;
944 return 0;
945}
946
947
948PyMethodDef boundarraymethod_methods[] = {

Callers 2

PyUFunc_ReduceWrapperFunction · 0.85
execute_ufunc_loopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected