MCPcopy Index your code
hub / github.com/RustPython/RustPython / rslice

Function rslice

Lib/test/test_buffer.py:711–717  ·  view source on GitHub ↗

Generate random slice for a single dimension of length n. If zero=True, the slices may be empty, otherwise they will be non-empty.

(n, allow_empty=False)

Source from the content-addressed store, hash-verified

709 return product(*iterables)
710
711def rslice(n, allow_empty=False):
712 """Generate random slice for a single dimension of length n.
713 If zero=True, the slices may be empty, otherwise they will
714 be non-empty."""
715 minlen = 0 if allow_empty or n == 0 else 1
716 slicelen = randrange(minlen, n+1)
717 return randslice_from_slicelen(slicelen, n)
718
719def rslices(n, allow_empty=False):
720 """Generate random slices for a single dimension."""

Callers 2

rslicesFunction · 0.85
rslices_ndimFunction · 0.85

Calls 1

randslice_from_slicelenFunction · 0.85

Tested by

no test coverage detected