Skip to main contentIBM Quantum Documentation

TwirledSliceSpan

class TwirledSliceSpan(start, stop, data_slices)

GitHub

An ExecutionSpan for data stored in a sliceable format when twirling.

This type of execution span references pub result data that came from a twirled sampler experiment which was executed by either prepending or appending an axis to paramater values to account for twirling. Concretely, data_slices is a map from pub slices to tuples (twirled_shape, at_front, shape_slice, shots_slice) where

  • twirled_shape is the shape tuple including a twirling axis, and where the last axis is shots per randomization,
  • at_front is whether num_randomizations is at the front of the tuple, as opposed to right before the shots axis at the end,
  • shape_slice is a slice of an array of shape twirled_shape[:-1], flattened,
  • and shots_slice is a slice of twirled_shape[-1].

Parameters

  • start (datetime) – The start time of the span, in UTC.
  • stop (datetime) – The stop time of the span, in UTC.
  • data_slices (dict[int, tuple[Tuple[int, ...], bool, slice, slice]]) – A map from pub indices to length-4 tuples described above.

Attributes

duration

The duration of this span, in seconds.

Return type

float

pub_idxs

Return type

list[int]

size

Return type

int

start

The start time of the span, in UTC.

Return type

datetime

stop

The stop time of the span, in UTC.

Return type

datetime


Methods

contains_pub

contains_pub(pub_idx)

GitHub

Return whether the pub with the given index has data with dependence on this span.

Parameters

pub_idx (int | Iterable[int]) – One or more pub indices from the original primitive call.

Return type

bool

Returns

Whether there is dependence on this span.

filter_by_pub

filter_by_pub(pub_idx)

GitHub

Return a new span whose slices are filtered to the provided pub indices.

For example, if this span contains slice information for pubs with indices 1, 3, 4 and [1, 4] is provided, then the span returned by this method will contain slice information for only those two indices, but be identical otherwise.

Parameters

pub_idx (int | Iterable[int]) – One or more pub indices from the original primitive call.

Return type

TwirledSliceSpan

Returns

A new filtered span.

mask

mask(pub_idx)

GitHub

Return an array-valued mask specifying which parts of a pub result depend on this span.

Parameters

pub_idx (int) – The index of the pub to return a mask for.

Return type

ndarray[Any, dtype[bool]]

Returns

An array with the same shape as the pub data.

Was this page helpful?
Report a bug or request content on GitHub.