* 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. */
| 911 | * NOTE: This function does not support `move_references` or inner dimensions. |
| 912 | */ |
| 913 | NPY_NO_EXPORT int |
| 914 | PyArrayMethod_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 | |
| 948 | PyMethodDef boundarraymethod_methods[] = { |
no outgoing calls
no test coverage detected