[Numpy-discussion] Inplace index suprise

James Philbin philbinj@gmail....
Thu Mar 20 12:42:05 CDT 2008


Hi,

I was suprised to see this result:
>>> import numpy as N
>>> A = N.array([0,0,0])
>>> A[[0,1,1,2]]+=1
>>> A
array([1, 1, 1])

Is this expected? Working on the principle of least surprise I would
expect [1,2,1] to be output.

Thanks,
James


More information about the Numpy-discussion mailing list