[Numpy-discussion] A Different Arithmetic Error: +=
Sasha
ndarray at mac.com
Tue Jul 18 13:54:41 EDT 2006
On 7/18/06, Alan G Isaac <aisaac at american.edu> wrote:
> it cannot upcast, as the '+=' operation will use only the
> memory initially allocated for a.
Not true:
>>> x = [2,3]
>>> x += array(2)
>>> type(x)
<type 'numpy.ndarray'>
This is just the design choice made by numpy.
I don't see the need for an error. Augmented assignment is a
sufficiently advanced
feature that those who use it can be expected to know what it does.
Loosing imaginary part maybe a more compelling reason for an error
than loosing precision, but it would be clearly wrong to have
different types behave differently. Silent downcasting from float to
int is actually a useful feature.
More information about the NumPy-Discussion
mailing list