[Numpy-discussion] CASTABLE flag
Mon Jan 7 14:16:46 CST 2008
Another possible approach is to treat downcasting similar to underflow. That
is give it it's own flag in the errstate and people can set it to ignore,
warn or raise on downcasting as desired. One could potentially have two
flags, one for downcasting across kinds (float->int, int->bool) and one for
downcasting within kinds (float64->float32). In this case, I personally
would set the first to raise and the second to ignore and would suggest that
as the default.
1. It's a no brainer to raise and exception when assigning a complex
value to a float or integer target. Using "Z.real" or "Z.imag" is
clearer and has the same performance.
2. I'm fairly dubious about assigning float to ints as is. First off
it looks like a bug magnet to me due to accidentally assigning a floating
point value to a target that one believes to be float but is in fact
integer. Second, C-style rounding is pretty evil; it's not always consistent
across platforms, so relying on it for anything other than truncating
already integral values is asking for trouble.
3. Downcasting within kinds seems much less hazardous than downcasting
across kinds, although I'd still be happy to be able regulate it with
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion