wrapped_slices#
- abtem.prism.utils.wrapped_slices(start, stop, n)[source]#
Two slices covering
[start, stop)on a periodic axis of lengthn.startmay be any integer. Normalising it into[0, n)first leaves only two cases – the window fits, or it wraps once – which is what two slices can express.The previous implementation assumed
-n <= start < nand0 < stop <= 2nand split on the raw values. For a window lying entirely in negative indices (stop <= 0) it producedslice(0, stop), which is Python’s negative indexing and selectsn + stopelements rather than none, so the two pieces concatenated ton + sizeelements instead ofsize. The mis-shaped array then surfaced as a broadcast error frames away from here.- Raises:
RuntimeError – If
stop - start > n. Two slices cannot cover more than one period;wrapped_crop_2dcatches this and takes its general path.- Return type:
Tuple[slice,slice]