22/11/10 @ 11:08 (-0800), thus spake Christopher Barker: > On 11/21/10 11:37 AM, Ernest Adrogué wrote: > >>so you want > >> > >>t[:,x,y] > > > >I tried that, but it's not the same: > > > >In [307]: t[[0,1],x,y] > >Out[307]: array([1, 7]) > > > >In [308]: t[:,x,y] > >Out[308]: > >array([[1, 3], > > [5, 7]]) > > what is your t? Here's my example, which I think matches what you asked for: > > In [1]: import numpy as np > > In [2]: a = np.arange(12) > > In [3]: a.shape = (3,2,2) > > In [4]: a > Out[4]: > array([[[ 0, 1], > [ 2, 3]], > > [[ 4, 5], > [ 6, 7]], > > [[ 8, 9], > [10, 11]]]) > > In [5]: a[:,1,0] > Out[5]: array([ 2, 6, 10])
This works with scalar indices, but not with arrays. The problem is that I don't want always the same element from each subarray, but an arbitrary element, say the (1,0) from the first, the (0,0) from the second, and so on, so I have to use arrays. -- Ernest _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
