MCPcopy Create free account
hub / github.com/apple/ml-pointersect / shuffle_along_axis

Function shuffle_along_axis

plib/sample_utils.py:92–107  ·  view source on GitHub ↗

Shuffle `arr` along `axis`. Args: arr: (*,) axis: Returns: (*,)

(arr: np.ndarray, axis: int, rng=None)

Source from the content-addressed store, hash-verified

90
91
92def shuffle_along_axis(arr: np.ndarray, axis: int, rng=None) -> np.ndarray:
93 """
94 Shuffle `arr` along `axis`.
95 Args:
96 arr:
97 (*,)
98 axis:
99
100 Returns:
101 (*,)
102 """
103 if rng is None:
104 rng = np.random
105
106 idx = rng.rand(*arr.shape).argsort(axis=axis)
107 return np.take_along_axis(arr, idx, axis=axis)

Callers 1

get_samplesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected