[Numpy-discussion] Do we want scalar casting to behave as it does at the moment?

Andrew Collette andrew.collette@gmail....
Tue Jan 8 18:35:42 CST 2013

Hi Olivier,

>> Yes, certainly.  But in either the proposed or 1.5 behavior, if the
>> values in x are close to the limits of the type, this can happen also.
> My previous email may not have been clear enough, so to be sure: in my above
> example, if the random number is 30000, then the result may contain negative
> values (int16). If the random number is 50000, then the result will only
> contain positive values (upcast to int32). Do you believe it is a good
> behavior?

Under the proposed behavior, if the random number is 30000, then you
*still* may have negative values, and if it's 50000, you get
ValueError.  No, I don't think the behavior you outlined is
particularly nice, but (1) it's consistent with array addition
elsewhere, at least in my mind, and (2) I don't think that sometimes
getting a ValueError is a big improvement.

Although I still prefer automatic upcasting, this discussion is really
making me see the value of a nice, simple rule like in 1.5. :)


More information about the NumPy-Discussion mailing list