[Numpy-discussion] fancy indexing question

Friedrich Romstedt friedrichromstedt@gmail....
Wed Aug 18 16:34:09 CDT 2010


2010/8/17 Angus McMorland <amcmorl@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