[Numpy-discussion] subtract.reduce behavior

Pauli Virtanen pav@iki...
Fri Jul 23 10:37:12 CDT 2010


Fri, 23 Jul 2010 11:17:56 -0400, Alan G Isaac wrote:
[clip]
> I also do not understand why there would have to be any special cases.

That's a technical issue: e.g. prod() is implemented via 
np.multiply.reduce, and it is not clear to me whether it is possible, in 
the ufunc machinery, to leave the identity undefined or whether it is 
needed in some code paths (as the right identity).

It's possible to define binary Ufuncs without an identity element (e.g. 
scipy.special.beta), so in principle the machinery to do the right thing 
is there.

> Returning a *right* identity for an operation that is otherwise a *left*
> fold is very odd, no matter how you slice it. That is what looks like
> special casing...

I think I see your point now.

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list