[Numpy-discussion] shuffle a slice

Keith Goodman kwgoodman at gmail.com
Sat May 29 14:35:13 EDT 2010


np.random.shuffle: "Modify a sequence in-place by shuffling its contents."

Matches doc string:

>> a = np.arange(10)
>> np.random.shuffle(a[:-1])
>> a
   array([0, 7, 8, 4, 3, 6, 2, 1, 5, 9])

Doesn't match doc string:

>> l = range(10)
>> np.random.shuffle(l[:-1])
>> l
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Is there any way for numpy to catch this?



More information about the NumPy-Discussion mailing list