pygsti.tools.slicetools.intersect_within

pygsti.tools.slicetools.intersect_within#

intersect_within(s1, s2)#

Returns the intersection of two slices (which must have the same step). and the sub-slice of s1 and s2 that specifies the intersection.

Furthermore, s2 may be an array of indices, in which case the returned slices become arrays as well.

Parameters:
  • s1 (slice) – First slice. Must have definite boundaries (start & stop cannot be None).

  • s2 (slice or numpy.ndarray) – Second slice or index array.

Returns:

  • intersection (slice or numpy.ndarray) – The intersection of s1 and s2.

  • subslice1 (slice or numpy.ndarray) – The portion of s1 that yields intersection.

  • subslice2 (slice or numpy.ndarray) – The portion of s2 that yields intersection.