* Call ufunc only on selected array items and store result in first operand. * For add ufunc, method call is equivalent to op1[idx] += op2 with no * buffering of the first operand. * Arguments: * op1 - First operand to ufunc * idx - Indices that are applied to first operand. Equivalent to op1[idx]. * op2 - Second operand to ufunc (if needed). Must be able to broadcast * over first ope
| 6246 | * over first operand. |
| 6247 | */ |
| 6248 | static PyObject * |
| 6249 | ufunc_at(PyUFuncObject *ufunc, PyObject *args) |
| 6250 | { |
| 6251 | PyObject *op1 = NULL; |
| 6252 | PyObject *idx = NULL; |
| 6253 | PyObject *op2 = NULL; |
| 6254 | PyArrayObject *op1_array = NULL; |
| 6255 | PyArrayObject *op2_array = NULL; |
| 6256 | PyArrayMapIterObject *iter = NULL; |
| 6257 | PyArrayIterObject *iter2 = NULL; |
| 6258 | PyArray_Descr *operation_descrs[3] = {NULL, NULL, NULL}; |
| 6259 | |
| 6260 | int nop; |
| 6261 | |
| 6262 | /* override vars */ |
| 6263 | int errval; |
| 6264 | PyObject *override = NULL; |
| 6265 | int res = -1; /* start with fail condition so "goto fail" will error */ |
| 6266 | |
| 6267 | PyArrayMethod_StridedLoop *strided_loop; |
| 6268 | NpyAuxData *auxdata = NULL; |
| 6269 | |
| 6270 | if (ufunc->core_enabled) { |
| 6271 | PyErr_Format(PyExc_TypeError, |
| 6272 | "%s.at does not support ufunc with non-trivial signature: %s has signature %s.", |
| 6273 | ufunc->name, ufunc->name, ufunc->core_signature); |
| 6274 | return NULL; |
| 6275 | } |
| 6276 | |
| 6277 | if (ufunc->nin > 2) { |
| 6278 | PyErr_SetString(PyExc_ValueError, |
| 6279 | "Only unary and binary ufuncs supported at this time"); |
| 6280 | return NULL; |
| 6281 | } |
| 6282 | |
| 6283 | if (ufunc->nout != 1) { |
| 6284 | PyErr_SetString(PyExc_ValueError, |
| 6285 | "Only single output ufuncs supported at this time"); |
| 6286 | return NULL; |
| 6287 | } |
| 6288 | |
| 6289 | if (!PyArg_ParseTuple(args, "OO|O:at", &op1, &idx, &op2)) { |
| 6290 | return NULL; |
| 6291 | } |
| 6292 | |
| 6293 | if (ufunc->nin == 2 && op2 == NULL) { |
| 6294 | PyErr_SetString(PyExc_ValueError, |
| 6295 | "second operand needed for ufunc"); |
| 6296 | return NULL; |
| 6297 | } |
| 6298 | |
| 6299 | if (ufunc->nin == 1 && op2 != NULL) { |
| 6300 | PyErr_SetString(PyExc_ValueError, |
| 6301 | "second operand provided when ufunc is unary"); |
| 6302 | return NULL; |
| 6303 | } |
| 6304 | errval = PyUFunc_CheckOverride(ufunc, "at", |
| 6305 | args, NULL, NULL, NULL, 0, NULL, &override); |
nothing calls this directly
no test coverage detected