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

Function validate_casting

numpy/core/src/umath/ufunc_object.c:1423–1446  ·  view source on GitHub ↗

* Check casting: It would be nice to just move this into the iterator * or pass in the full cast information. But this can special case * the logical functions and prints a better error message. */

Source from the content-addressed store, hash-verified

1421 * the logical functions and prints a better error message.
1422 */
1423static inline int
1424validate_casting(PyArrayMethodObject *method, PyUFuncObject *ufunc,
1425 PyArrayObject *ops[], PyArray_Descr *descriptors[],
1426 NPY_CASTING casting)
1427{
1428 if (method->resolve_descriptors == &wrapped_legacy_resolve_descriptors) {
1429 /*
1430 * In this case the legacy type resolution was definitely called
1431 * and we do not need to check (astropy/pyerfa relied on this).
1432 */
1433 return 0;
1434 }
1435 if (method->flags & _NPY_METH_FORCE_CAST_INPUTS) {
1436 if (PyUFunc_ValidateOutCasting(ufunc, casting, ops, descriptors) < 0) {
1437 return -1;
1438 }
1439 }
1440 else {
1441 if (PyUFunc_ValidateCasting(ufunc, casting, ops, descriptors) < 0) {
1442 return -1;
1443 }
1444 }
1445 return 0;
1446}
1447
1448
1449/*

Callers 4

execute_ufunc_loopFunction · 0.85

Calls 2

PyUFunc_ValidateCastingFunction · 0.85

Tested by

no test coverage detected