* Helper function for casting a raw value from one descriptor to another. * This helper uses the normal casting machinery, but e.g. does not care about * checking cast safety. */
| 387 | * checking cast safety. |
| 388 | */ |
| 389 | static int |
| 390 | cast_raw_scalar_item( |
| 391 | PyArray_Descr *from_descr, char *from_item, |
| 392 | PyArray_Descr *to_descr, char *to_item) |
| 393 | { |
| 394 | NPY_cast_info cast_info; |
| 395 | NPY_ARRAYMETHOD_FLAGS flags; |
| 396 | if (PyArray_GetDTypeTransferFunction( |
| 397 | 0, 0, 0, from_descr, to_descr, 0, &cast_info, |
| 398 | &flags) == NPY_FAIL) { |
| 399 | return -1; |
| 400 | } |
| 401 | |
| 402 | if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) { |
| 403 | npy_clear_floatstatus_barrier(from_item); |
| 404 | } |
| 405 | |
| 406 | char *args[2] = {from_item, to_item}; |
| 407 | const npy_intp strides[2] = {0, 0}; |
| 408 | const npy_intp length = 1; |
| 409 | if (cast_info.func(&cast_info.context, |
| 410 | args, &length, strides, cast_info.auxdata) < 0) { |
| 411 | NPY_cast_info_xfree(&cast_info); |
| 412 | return -1; |
| 413 | } |
| 414 | NPY_cast_info_xfree(&cast_info); |
| 415 | |
| 416 | if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) { |
| 417 | int fpes = npy_get_floatstatus_barrier(to_item); |
| 418 | if (fpes && PyUFunc_GiveFloatingpointErrors("cast", fpes) < 0) { |
| 419 | return -1; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | |
| 427 | /** |
no test coverage detected