When applying two different slicing operations in succession (e.g. select a sub-range, then select using a binary mask) it seems that numpy arrays can be inconsistent with respect to assignment:
For example, in this case an array is modified: In [6]: *A = np.arange(5)* In [8]: *A[:][A>2] = 0* In [10]: A Out[10]: *array([0, 1, 2, 0, 0])* Whereas here the original array remains unchanged In [11]: *A = np.arange(5)* In [12]: *A[[0,1,2,3,4]][A>2] = 0* In [13]: A Out[13]: *array([0, 1, 2, 3, 4])* This arose in a less contrived situation in which I was trying to copy a small image into a large image, modulo a mask on the small image. Is this meant to be like this? Alex
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion