summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-01-06 13:34:22 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2022-01-06 14:35:45 -0600
commitca976a18cf90573559d9085ac6fc522eabbf77b4 (patch)
treed040043a47e6a38766406344662566b31ea768e3 /numpy
parent1684a933d6e4efa260434fd13b67a8ef34db7eca (diff)
downloadnumpy-ca976a18cf90573559d9085ac6fc522eabbf77b4.tar.gz
MAINT: Relax asserts to match relaxed reducelike resolution behaviour
This closes gh-20751, which was due to the assert not being noticed triggered (not sure why) during initial CI run. The behaviour is relaxed, so the assert must also be relaxed.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/ufunc_object.c16
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 */