Create two sets of slices for an array x with shape 'shape' such that shapeof(x[lslices]) == shapeof(x[rslices]).
(ndim, shape)
| 570 | return s |
| 571 | |
| 572 | def randslice_from_shape(ndim, shape): |
| 573 | """Create two sets of slices for an array x with shape 'shape' |
| 574 | such that shapeof(x[lslices]) == shapeof(x[rslices]).""" |
| 575 | lslices = [0] * ndim |
| 576 | rslices = [0] * ndim |
| 577 | for n in range(ndim): |
| 578 | l = shape[n] |
| 579 | slicelen = randrange(1, l+1) if l > 0 else 0 |
| 580 | lslices[n] = randslice_from_slicelen(slicelen, l) |
| 581 | rslices[n] = randslice_from_slicelen(slicelen, l) |
| 582 | return tuple(lslices), tuple(rslices) |
| 583 | |
| 584 | def rand_aligned_slices(maxdim=5, maxshape=16): |
| 585 | """Create (lshape, rshape, tuple(lslices), tuple(rslices)) such that |
no test coverage detected