[Numpy-discussion] permutation and array subsets

Serge Rey serge at rohan.sdsu.edu
Wed Aug 8 00:38:30 EDT 2001

i'm trying to use the results of permutation (from RandomArray.py) to
reorder the rows of an array:

>>> r=arange(20)
>>> id=permutation(20)
>>> y=r[id]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  IndexError: invalid index

i can use a for loop to permutate the ordering of r, but that has a
speed hit associated with it.  can anyone offer a suggestion for a way
to do this more efficiently? 

Sergio J. Rey	http://typhoon.sdsu.edu/rey.html

More information about the NumPy-Discussion mailing list