Skip to content

Commit 4c75113

Browse files
committed
BUG: enforce 'ret is ouf' for 'ret = einsum(..., out=out)'
1 parent f93ed4f commit 4c75113

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎numpy/core/src/multiarray/einsum.c.src‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2769,8 +2769,11 @@ PyArray_EinsteinSum(char *subscripts, npy_intp nop,
27692769

27702770
/* Initialize the output to all zeros and reset the iterator */
27712771
ret = NpyIter_GetOperandArray(iter)[nop];
2772-
Py_INCREF(ret);
27732772
PyArray_AssignZero(ret, NULL);
2773+
if (out) {
2774+
ret = out;
2775+
}
2776+
Py_INCREF(ret);
27742777

27752778

27762779
/***************************/

0 commit comments

Comments
 (0)