[Numpy-discussion] fancy indexing question

Friedrich Romstedt friedrichromstedt at gmail.com
Wed Aug 18 17:34:09 EDT 2010


2010/8/17 Angus McMorland <amcmorl at gmail.com>:
> 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



More information about the NumPy-Discussion mailing list