Create a random slice of len slicelen that fits into listlen.
(slicelen, listlen)
| 557 | return memlen, itemsize, ndim, shape, strides, offset |
| 558 | |
| 559 | def randslice_from_slicelen(slicelen, listlen): |
| 560 | """Create a random slice of len slicelen that fits into listlen.""" |
| 561 | maxstart = listlen - slicelen |
| 562 | start = randrange(maxstart+1) |
| 563 | maxstep = (listlen - start) // slicelen if slicelen else 1 |
| 564 | step = randrange(1, maxstep+1) |
| 565 | stop = start + slicelen * step |
| 566 | s = slice(start, stop, step) |
| 567 | _, _, _, control = slice_indices(s, listlen) |
| 568 | if control != slicelen: |
| 569 | raise RuntimeError |
| 570 | return s |
| 571 | |
| 572 | def randslice_from_shape(ndim, shape): |
| 573 | """Create two sets of slices for an array x with shape 'shape' |
no test coverage detected