[Numpy-discussion] Inplace index suprise

James Philbin philbinj at gmail.com
Thu Mar 20 05:31:42 EDT 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