[Numpy-discussion] Can not update a submatrix

Nadav Horesh nadavh@visionsense....
Wed Jan 30 07:42:20 CST 2008


In the following piece of code:

>>> import numpy as N
>>> R = N.arange(9).reshape(3,3)
>>> ax = [1,2]
>>> R
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
>>> R[ax,:][:,ax] = 100
>>> R
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])

Why R is not updated?

I was expecting:

>>> R
array([[0, 1, 2],
       [3, 100, 100],
       [6, 100, 100]])

I am using numpy 1.04 on gentoo-linux/amd64

  Nadav

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080130/d899772c/attachment.html 


More information about the Numpy-discussion mailing list