summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-05-05 10:32:22 -0500
committerSebastian Berg <sebastian@sipsolutions.net>2021-05-05 10:32:22 -0500
commit6786740d5382273ec9f875e4586744e35858c206 (patch)
tree4851d9e2e77e702622606faeae7f6427e67098fa
parente684d66262626901cd2715e48ac8141c90cbae00 (diff)
downloadnumpy-6786740d5382273ec9f875e4586744e35858c206.tar.gz
Limit special handling to output dtypes in uniform resolver
-rw-r--r--numpy/core/src/umath/ufunc_type_resolution.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/core/src/umath/ufunc_type_resolution.c b/numpy/core/src/umath/ufunc_type_resolution.c
index 8f974fca0..0be85c1c4 100644
--- a/numpy/core/src/umath/ufunc_type_resolution.c
+++ b/numpy/core/src/umath/ufunc_type_resolution.c
@@ -555,7 +555,7 @@ PyUFunc_SimpleUniformOperationTypeResolver(
* one in the tuple), there is no need to check all loops.
* Note that this also allows (None, None, float64) to resolve to
* (float64, float64, float64), even when the inputs do not match,
- * i.e. fixing a single part of the signature can fix all of them.
+ * i.e. fixing the output part of the signature can fix all of them.
* This is necessary to support `nextafter(1., inf, dtype=float32)`,
* where it is "clear" we want to cast 1. and inf to float32.
*/
@@ -565,7 +565,12 @@ PyUFunc_SimpleUniformOperationTypeResolver(
for (int i = 0; i < nop; i++) {
PyObject *item = PyTuple_GET_ITEM(type_tup, i);
if (item == Py_None) {
- continue;
+ if (i < ufunc->nin) {
+ continue;
+ }
+ /* All outputs must be set (this could be relaxed) */
+ descr = NULL;
+ break;
}
if (!PyArray_DescrCheck(item)) {
/* Defer to default resolver (will raise an error there) */