On Wed, 14 Jun 2006 11:14:17 +0200 Martin Wiechert <[EMAIL PROTECTED]> wrote:
> > Hi list, > > is there a concise way to address a subrectangle of a 2d array? So far I'm > using > > A [I] [:, J] what about A[I,J] ? Simon. >>> import numpy >>> a=numpy.zer numpy.zeros numpy.zeros_like >>> a=numpy.zeros([4,4]) >>> a array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) >>> a[2:3,2:3]=1 >>> a array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) >>> a[1:3,1:3]=1 >>> a array([[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) >>> -- Simon Burton, B.Sc. Licensed PO Box 8066 ANU Canberra 2601 Australia Ph. 61 02 6249 6940 http://arrowtheory.com _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion