[Numpy-discussion] coercion rules for float32 in numpy are different from numarray
oliphant.travis at ieee.org
Fri Aug 25 07:50:32 CDT 2006
Sebastian Haase wrote:
>> This is now the behavior in SVN. Note that this is different from both
>> Numeric (which gave an error) and numarray (which coerced to float32).
>> But, it is consistent with how mixed-types are handled in calculations
>> and is thus an easier rule to explain.
>> Thanks for the testing.
> How hard would it be to change the rules back to the numarray behavior ?
It wouldn't be hard, but I'm not so sure that's a good idea. I do see
the logic behind that approach and it is worthy of some discussion.
I'll give my current opinion:
The reason I changed the behavior is to get consistency so there is one
set of rules on mixed-type interaction to explain. You can always do
what you want by force-casting your int32 arrays to float32. There
will always be some people who don't like whichever behavior is
selected, but we are trying to move NumPy in a direction of consistency
with fewer exceptions to explain (although this is a guideline and not
an absolute requirement).
Mixed-type interaction is always somewhat ambiguous. Now there is a
consistent rule for both universal functions and other functions (move
to a precision where both can be safely cast to --- unless one is a
scalar and then its precision is ignored).
If you don't want that to happen, then be clear about what data-type
should be used by casting yourself. In this case, we should probably
not try and guess about what users really want in mixed data-type
More information about the Numpy-discussion