* The default method to fetch the correct loop for a cast or ufunc * (at the time of writing only casts). * Note that the default function provided here will only indicate that a cast * can be done as a view (i.e., arr.view(new_dtype)) when this is trivially * true, i.e., for cast safety "no-cast". It will not recognize view as an * option for other casts (e.g., viewing '>i8' as '>i4' with an
| 134 | * @return 0 on success -1 on failure. |
| 135 | */ |
| 136 | NPY_NO_EXPORT int |
| 137 | npy_default_get_strided_loop( |
| 138 | PyArrayMethod_Context *context, |
| 139 | int aligned, int NPY_UNUSED(move_references), const npy_intp *strides, |
| 140 | PyArrayMethod_StridedLoop **out_loop, NpyAuxData **out_transferdata, |
| 141 | NPY_ARRAYMETHOD_FLAGS *flags) |
| 142 | { |
| 143 | PyArray_Descr **descrs = context->descriptors; |
| 144 | PyArrayMethodObject *meth = context->method; |
| 145 | *flags = meth->flags & NPY_METH_RUNTIME_FLAGS; |
| 146 | *out_transferdata = NULL; |
| 147 | |
| 148 | int nargs = meth->nin + meth->nout; |
| 149 | if (aligned) { |
| 150 | if (meth->contiguous_loop == NULL || |
| 151 | !is_contiguous(strides, descrs, nargs)) { |
| 152 | *out_loop = meth->strided_loop; |
| 153 | return 0; |
| 154 | } |
| 155 | *out_loop = meth->contiguous_loop; |
| 156 | } |
| 157 | else { |
| 158 | if (meth->unaligned_contiguous_loop == NULL || |
| 159 | !is_contiguous(strides, descrs, nargs)) { |
| 160 | *out_loop = meth->unaligned_strided_loop; |
| 161 | return 0; |
| 162 | } |
| 163 | *out_loop = meth->unaligned_contiguous_loop; |
| 164 | } |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | |
| 169 | /** |
no test coverage detected