---
title: TwirledSliceSpan (latest version)
description: API reference for qiskit_ibm_runtime.execution_span.TwirledSliceSpan in the latest version of qiskit-ibm-runtime
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/execution-span-twirled-slice-span
---

# TwirledSliceSpan

*class* `TwirledSliceSpan(start, stop, data_slices)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/execution_span/twirled_slice_span.py#L33-L108)

Bases: [`ExecutionSpan`](/docs/api/qiskit-ibm-runtime/execution-span-execution-span "qiskit_ibm_runtime.execution_span.execution_span.ExecutionSpan")

An [`ExecutionSpan`](/docs/api/qiskit-ibm-runtime/execution-span-execution-span "qiskit_ibm_runtime.execution_span.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 parameter 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** (*Mapping\[int, tuple\[ShapeType, bool, slice, slice]]*) – A map from pub indices to length-4 tuples described above.

## Attributes

### duration

The duration of this span, in seconds.

### pub\_idxs

Which pubs, by index, have dependence on one or more execution spans present.

### size

The total number of results with dependence on this execution span, across all pubs.

### start

The start time of the span, in UTC.

### stop

The stop time of the span, in UTC.

## Methods

### contains\_pub

`contains_pub(pub_idx)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/execution_span/execution_span.py#L117-L127)

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.

**Returns**

Whether there is dependence on this span.

**Return type**

bool

### filter\_by\_pub

`filter_by_pub(pub_idx)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/execution_span/twirled_slice_span.py#L104-L108)

Return a new set of spans where each one has been filtered to the specified pubs.

**Parameters**

**pub\_idx** (*int | Iterable\[int]*)

**Return type**

[TwirledSliceSpan](#qiskit_ibm_runtime.execution_span.TwirledSliceSpan "qiskit_ibm_runtime.execution_span.TwirledSliceSpan")

### mask

`mask(pub_idx)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/execution_span/twirled_slice_span.py#L84-L102)

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

**Parameters**

**pub\_idx** (*int*)

**Return type**

npt.NDArray\[np.bool\_]
