pygsti.tools.slicetools

pygsti.tools.slicetools#

Utility functions for working with Python slice objects

Functions

divide(slc, max_len)

Divides a slice into sub-slices based on a maximum length (for each sub-slice).

indices(s[, n])

Returns a list of the indices specified by slice s.

indices_as_array(s[, n])

Returns a numpy array of the indices specified by slice s.

intersect(s1, s2)

Returns the intersection of two slices (which must have the same step).

intersect_within(s1, s2)

Returns the intersection of two slices (which must have the same step).

length(s)

Returns the length (the number of indices) contained in a slice.

list_to_slice(lst[, array_ok, ...])

Returns a slice corresponding to a given list of (integer) indices, if this is possible.

shift(s, offset)

Returns a new slice whose start and stop points are shifted by offset.

slice_hash(slc)

slice_of_slice(slc, base_slc)

A slice that is the composition of base_slc and slc.

to_array(slc_or_list_like)

Returns slc_or_list_like as an index array (an integer numpy.ndarray).