diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2022-01-06 14:38:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 14:38:14 -0700 |
commit | 4e436ff0c83f21b82495954a3c3c85814de40f83 (patch) | |
tree | fbced26dbf5eef509e196a805882251154395672 /numpy | |
parent | 44b9cdb17c074daa0e5d747f02c45a49ad6d786a (diff) | |
parent | ca976a18cf90573559d9085ac6fc522eabbf77b4 (diff) | |
download | numpy-4e436ff0c83f21b82495954a3c3c85814de40f83.tar.gz |
Merge pull request #20754 from seberg/fixup-relax-dtype-identity
MAINT: Relax asserts to match relaxed reducelike resolution behaviour
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 83e18a363..415ff0f07 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -3032,8 +3032,12 @@ PyUFunc_Accumulate(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *out, return NULL; } - /* The below code assumes that all descriptors are identical: */ - assert(descrs[0] == descrs[1] && descrs[0] == descrs[2]); + /* + * The below code assumes that all descriptors are interchangeable, we + * allow them to not be strictly identical (but they typically should be) + */ + assert(PyArray_EquivTypes(descrs[0], descrs[1]) + && PyArray_EquivTypes(descrs[0], descrs[2])); if (PyDataType_REFCHK(descrs[2]) && descrs[2]->type_num != NPY_OBJECT) { /* This can be removed, but the initial element copy needs fixing */ @@ -3445,8 +3449,12 @@ PyUFunc_Reduceat(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *ind, return NULL; } - /* The below code assumes that all descriptors are identical: */ - assert(descrs[0] == descrs[1] && descrs[0] == descrs[2]); + /* + * The below code assumes that all descriptors are interchangeable, we + * allow them to not be strictly identical (but they typically should be) + */ + assert(PyArray_EquivTypes(descrs[0], descrs[1]) + && PyArray_EquivTypes(descrs[0], descrs[2])); if (PyDataType_REFCHK(descrs[2]) && descrs[2]->type_num != NPY_OBJECT) { /* This can be removed, but the initial element copy needs fixing */ |