2010/8/17 Angus McMorland :
> a = np.random.randint(10, size=(4,3,2))
> ord = np.array([[3,2,1,0],[0,2,1,3],[3,0,2,1]]).T
> b = a[ord][:,np.eye(3, dtype=bool),:]
b = a[ord, arange(0, 3)]
Broadcasting rules!
Tested.
Friedrich
___
NumPy-Discussion maili
On Tue, Aug 17, 2010 at 11:30 AM, Angus McMorland wrote:
> Hi all,
>
> I'm having a bit of a brain block about the following fancy indexing
> question, and am hoping someone can point me in the right direction. I
> have a 3-d array `a` that I want to reorder along its 0th dimension
> differently f
Hi all,
I'm having a bit of a brain block about the following fancy indexing
question, and am hoping someone can point me in the right direction. I
have a 3-d array `a` that I want to reorder along its 0th dimension
differently for each 1st dimension, with the indices given in a 2-d
array `ord`. I
Ravi wrote:
> Use ix_:
>
> In [5]: a[ ix_(i,j) ]
> Out[5]:
> array([[ 5, 7],
>[13, 15],
>[17, 19]])
Very nice!
thanks,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959 voice
7600 Sand Point Way NE (20
On Tuesday 24 February 2009 14:39:39 Christopher Barker wrote:
> I'm having a bit of trouble getting fancy indexing to do what I want.
Use ix_:
In [2]: a
Out[2]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15],
[16, 17, 18, 19],
[20
On Tue, Feb 24, 2009 at 1:39 PM, Christopher Barker
wrote:
> HI all,
>
> I'm having a bit of trouble getting fancy indexing to do what I want.
>
> Say I have a 2-d array:
>
> >>> a
> array([[ 0, 1, 2, 3],
>[ 4, 5, 6, 7],
>[ 8, 9, 10, 11],
>[12, 13, 14, 15],
>
Robert Kern wrote:
> On Tue, Feb 24, 2009 at 13:39, Christopher Barker
> wrote:
>> >>> a
>> array([[ 0, 1, 2, 3],
>>[ 4, 5, 6, 7],
>>[ 8, 9, 10, 11],
>>[12, 13, 14, 15],
>>[16, 17, 18, 19],
>>[20, 21, 22, 23]])
>>
>> I want to extract a sub-array:
On Tue, Feb 24, 2009 at 13:39, Christopher Barker wrote:
> HI all,
>
> I'm having a bit of trouble getting fancy indexing to do what I want.
>
> Say I have a 2-d array:
>
> >>> a
> array([[ 0, 1, 2, 3],
> [ 4, 5, 6, 7],
> [ 8, 9, 10, 11],
> [12, 13, 14, 15],
> [
HI all,
I'm having a bit of trouble getting fancy indexing to do what I want.
Say I have a 2-d array:
>>> a
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]])
I want to extract a sub-array: