Re: problems with duplicating and slicing an array

2005-01-22 Thread David Isaac
Yun Mao wrote: >a[ [1,0], [0,1] ] , which should give me >[[4, 5], [1,2]] Numeric: take(take(a,[1,0]),[0,1],1) fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: problems with duplicating and slicing an array

2005-01-21 Thread Steven Bethard
py> import numarray as na py> a = na.array([[1,2,3],[4,5,6]]) Yun Mao wrote: Thanks for the help. numarray doesn't provide what I look for either. e.g. a = array( [[1,2,3],[4,5,6]] ) I sometimes what this: a[ [1,0], :], py> a[[1,0]] array([[4, 5, 6], [1, 2, 3]]) or even a[ [1,0], [0,1] ]

Re: problems with duplicating and slicing an array

2005-01-21 Thread beliavsky
Yun Mao wrote: >Thanks for the help. numarray doesn't provide what I look for either. e.g. >a = array( [[1,2,3],[4,5,6]] ) >I sometimes what this: a[ [1,0], :], or even >a[ [1,0], [0,1] ] , which should give me >[[4, 5], [1,2]] I think Fortran 90 and 95 have the array slicing you want. For examp

Re: problems with duplicating and slicing an array

2005-01-20 Thread Yun Mao
Hi all, Thanks for the help. numarray doesn't provide what I look for either. e.g. a = array( [[1,2,3],[4,5,6]] ) I sometimes what this: a[ [1,0], :], or even a[ [1,0], [0,1] ] , which should give me [[4, 5], [1,2]] Because I don't really care about arrays with dimension >2, I did a little h

Re: problems with duplicating and slicing an array

2005-01-20 Thread John Hunter
> "Yun" == Yun Mao <[EMAIL PROTECTED]> writes: Yun> 2. Is there a way to do Matlab style slicing? e.g. if I have Yun> i = array([0, 2]) x = array([1.1, 2.2, 3.3, 4.4]) I wish y = Yun> x(i) would give me [1.1, 3.3] Now I'm using map, but it gets Yun> a little annoying when there

Re: problems with duplicating and slicing an array

2005-01-20 Thread beliavsky
Yun Mao wrote: >I have some questions when I'm using python numeric: >1. When I do v = u[:, :], it seems u and v still point to the same >memory. e.g. When I do v[1,1]=0, u[1,1] will be zero out as well. >What's the right way to duplicate an array? Now I have to do v = >dot(u, identity(N)), which

Re: problems with duplicating and slicing an array

2005-01-20 Thread Steven Bethard
Yun Mao wrote: Hi python gurus, I have some questions when I'm using python numeric: 1. When I do v = u[:, :], it seems u and v still point to the same memory. e.g. When I do v[1,1]=0, u[1,1] will be zero out as well. What's the right way to duplicate an array? Now I have to do v = dot(u, identi

problems with duplicating and slicing an array

2005-01-20 Thread Yun Mao
Hi python gurus, I have some questions when I'm using python numeric: 1. When I do v = u[:, :], it seems u and v still point to the same memory. e.g. When I do v[1,1]=0, u[1,1] will be zero out as well. What's the right way to duplicate an array? Now I have to do v = dot(u, identity(N)), which