cmp_arg_types(int *arg1, int *arg2, int n) { while (n--) { if (PyArray_EquivTypenums(*arg1, *arg2)) continue; if (PyArray_CanCastSafely(*arg1, *arg2)) return -1; return 1; } return 0; } IIUC, if can cast (arg1, arg2), we never compare other args, just return -1. Shouldn't this be: cmp_arg_types(int *arg1, int *arg2, int n) { while (n--) { if (PyArray_EquivTypenums(*arg1, *arg2) or (PyArray_CanCastSafely(*arg1, *arg2)) continue; return 1; } return 0; }
Neal Becker wrote:
cmp_arg_types(int *arg1, int *arg2, int n) { while (n--) { if (PyArray_EquivTypenums(*arg1, *arg2)) continue; if (PyArray_CanCastSafely(*arg1, *arg2)) return -1; return 1; } return 0; }
IIUC, if can cast (arg1, arg2), we never compare other args, just return -1.
Shouldn't this be: cmp_arg_types(int *arg1, int *arg2, int n) { while (n--) { if (PyArray_EquivTypenums(*arg1, *arg2) or (PyArray_CanCastSafely(*arg1, *arg2)) continue; return 1; } return 0; }
Oh, better make that: static int cmp_arg_types(int *arg1, int *arg2, int n) { for (;n > 0; n--, ++arg1, ++arg2) { if (PyArray_EquivTypenums(*arg1, *arg2) || PyArray_CanCastSafely(*arg1, *arg2)) continue; return 1; } return 0; }
participants (1)
-
Neal Becker