---
title: SliceSpan (v0.41)
description: API reference for qiskit_ibm_runtime.execution_span.SliceSpan in qiskit-ibm-runtime v0.41
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/0.41/execution-span-slice-span
---

# SliceSpan

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

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.41/qiskit_ibm_runtime/execution_span/slice_span.py#L27-L77)

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

An [`ExecutionSpan`](/docs/api/qiskit-ibm-runtime/0.41/execution-span-execution-span "qiskit_ibm_runtime.execution_span.ExecutionSpan") for data stored in a sliceable format.

This type of execution span references pub result data by assuming that it is a sliceable portion of the (row major) flattened data. Therefore, for each pub dependent on this span, the constructor accepts a single `slice` object, along with the corresponding shape of the data to be sliced.

**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\[ShapeType, slice]]*) – A map from pub indices to pairs `(shape_tuple, slice)`.

## Attributes

### duration

The duration of this span, in seconds.

### pub\_idxs

### size

### 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.41/qiskit_ibm_runtime/execution_span/execution_span.py#L115-L125)

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.41/qiskit_ibm_runtime/execution_span/slice_span.py#L74-L77)

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.

**Returns**

A new filtered span.

**Return type**

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

### mask

`mask(pub_idx)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.41/qiskit_ibm_runtime/execution_span/slice_span.py#L65-L72)

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.

**Returns**

An array with the same shape as the pub data.

**Raises**

**KeyError** – if the pub is not included in the span

**Return type**

[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)\[*Any*, [*dtype*](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype)\[[*bool*](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.bool)]]
