Multi-dimensional slice assignment: llst and rlst are the operands, lslices and rslices are lists of slice objects. llst and rlst must have the same structure. For a two-dimensional example, this is not implemented in Python: llst[0:3:2, 0:3:2] = rlst[1:3:1, 1:3:1]
(llst, rlst, lslices, rslices)
| 388 | return [multislice(sublst, slices[1:]) for sublst in lst[slices[0]]] |
| 389 | |
| 390 | def m_assign(llst, rlst, lslices, rslices): |
| 391 | """Multi-dimensional slice assignment: llst and rlst are the operands, |
| 392 | lslices and rslices are lists of slice objects. llst and rlst must |
| 393 | have the same structure. |
| 394 | |
| 395 | For a two-dimensional example, this is not implemented in Python: |
| 396 | |
| 397 | llst[0:3:2, 0:3:2] = rlst[1:3:1, 1:3:1] |
| 398 | |
| 399 | Instead we write: |
| 400 | |
| 401 | lslices = [slice(0,3,2), slice(0,3,2)] |
| 402 | rslices = [slice(1,3,1), slice(1,3,1)] |
| 403 | multislice_assign(llst, rlst, lslices, rslices) |
| 404 | """ |
| 405 | if atomp(rlst): |
| 406 | return rlst |
| 407 | rlst = [m_assign(l, r, lslices[1:], rslices[1:]) |
| 408 | for l, r in zip(llst[lslices[0]], rlst[rslices[0]])] |
| 409 | llst[lslices[0]] = rlst |
| 410 | return llst |
| 411 | |
| 412 | def cmp_structure(llst, rlst, lslices, rslices): |
| 413 | """Compare the structure of llst[lslices] and rlst[rslices].""" |
no test coverage detected
searching dependent graphs…