[Numpy-discussion] A Different Arithmetic Error: +=

Alan G Isaac aisaac at american.edu
Tue Jul 18 04:10:49 EDT 2006


On Mon, 17 Jul 2006, John Lawless apparently wrote:
>>>> from scipy import *
>>>> a = array((1.2))
>>>> a += 1.3j
>>>> a
> array(1.2)
> Shouldn't this generate either an error or an up-cast, rather than
> silently discarding the imaginary part?

As I understand it:
it cannot upcast, as the '+=' operation will use only the
memory initially allocated for a.

Cheers,
Alan Isaac







More information about the NumPy-Discussion mailing list