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

Alan G Isaac aisaac at american.edu
Tue Jul 18 03:10:49 CDT 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