slice_index

zixy.utils.slice_index(s: slice, i: int, length: int) int[source]

Find an index in the original sequence corresponding to index i of slice s.

Parameters:
  • s – The slice object.

  • i – Zero-based index relative to the slice.

  • length – Length of the sequence being sliced.

Returns:

The index in the original sequence corresponding to index i of slice s.

Raises:

IndexError – If i is out of the slice bounds.