MCPcopy Create free account
hub / github.com/numpy/numpy / random_slice

Function random_slice

numpy/core/tests/test_mem_overlap.py:240–246  ·  view source on GitHub ↗
(n, step)

Source from the content-addressed store, hash-verified

238 raise ValueError()
239
240 def random_slice(n, step):
241 start = rng.randint(0, n+1, dtype=np.intp)
242 stop = rng.randint(start, n+1, dtype=np.intp)
243 if rng.randint(0, 2, dtype=np.intp) == 0:
244 stop, start = start, stop
245 step *= -1
246 return slice(start, stop, step)
247
248 def random_slice_fixed_size(n, step, size):
249 start = rng.randint(0, n+1 - size*step)

Callers 2

iter_random_view_pairsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected