Create two sets of slices for an array x with shape 'shape' such that shapeof(x[lslices]) == shapeof(x[rslices]).
(ndim, shape)
| 582 | return s |
| 583 | |
| 584 | def randslice_from_shape(ndim, shape): |
| 585 | """Create two sets of slices for an array x with shape 'shape' |
| 586 | such that shapeof(x[lslices]) == shapeof(x[rslices]).""" |
| 587 | lslices = [0] * ndim |
| 588 | rslices = [0] * ndim |
| 589 | for n in range(ndim): |
| 590 | l = shape[n] |
| 591 | slicelen = randrange(1, l+1) if l > 0 else 0 |
| 592 | lslices[n] = randslice_from_slicelen(slicelen, l) |
| 593 | rslices[n] = randslice_from_slicelen(slicelen, l) |
| 594 | return tuple(lslices), tuple(rslices) |
| 595 | |
| 596 | def rand_aligned_slices(maxdim=5, maxshape=16): |
| 597 | """Create (lshape, rshape, tuple(lslices), tuple(rslices)) such that |
no test coverage detected
searching dependent graphs…