MCPcopy Index your code
hub / github.com/python/cpython / rslice

Function rslice

Lib/test/test_buffer.py:723–729  ·  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

721 return product(*iterables)
722
723def rslice(n, allow_empty=False):
724 """Generate random slice for a single dimension of length n.
725 If zero=True, the slices may be empty, otherwise they will
726 be non-empty."""
727 minlen = 0 if allow_empty or n == 0 else 1
728 slicelen = randrange(minlen, n+1)
729 return randslice_from_slicelen(slicelen, n)
730
731def rslices(n, allow_empty=False):
732 """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

Used in the wild real call sites across dependent graphs

searching dependent graphs…