flopscope.numpy.random.shuffle
fnp.random.shuffle(x)[flopscope source]
Modify a sequence in-place by shuffling its contents.
Adapted from NumPy docs np.random.shuffle
Cost
per-operation
Flopscope Context
Shuffle; cost = n*ceil(log2(n)).
This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.
Note.
New code should use the shuffle method of a Generator instance instead; please see the random-quick-start.
Parameters
- x:ndarray or MutableSequence
The array, list or mutable sequence to be shuffled.
Returns
- :None
See also
- we.flops.random.Generator.shuffle which should be used for new code.
Examples
>>> arr = flops.arange(10)
>>> flops.random.shuffle(arr)
>>> arr
[1 7 5 2 9 4 3 6 0 8] # randomMulti-dimensional arrays are only shuffled along the first axis:
>>> arr = flops.arange(9).reshape((3, 3))
>>> flops.random.shuffle(arr)
>>> arr
array([[3, 4, 5], # random
[6, 7, 8],
[0, 1, 2]])