[Numpy-discussion] Add/multiply reduction confusion
Sun Jul 5 13:47:18 CDT 2009
Stéfan van der Walt wrote:
> 2009/7/5 Andrew Friedley <email@example.com>:
>> I found the check that does the type 'upcasting' in
>> umath_ufunc_object.inc around line 3072 (NumPy 1.3.0). Turns out all I
>> need to do is make sure my add and multiply ufuncs are actually named
>> 'add' and 'multiply' and arrays will be upcasted appropriately.
> Would you please be so kind as to add your findings here:
> I haven't read through that document recently, so it may be in there already.
I created an account (afriedle) but looks like I don't have edit
The user-side upcasting behavior for add/multiply is documented (though
a little hidden) in the long paragraph right before the 'Available
I'm thinking something should be added on the C API side though, perhaps
on the 'name' parameter of PyUFunc_FromFuncAndData():
I would say something to the effect of (I borrowed from the user-side
blurb :) :
Specifying a name of 'add' or 'multiply' enables a special behavior for
integer-typed reductions when no dtype is given. If the input type is
an integer (or boolean) data type smaller than the size of the int_ data
type, it will be internally upcast to the int_ (or uint) data type.
More information about the NumPy-Discussion