Observable grouping (qiskit_addon_cutting.utils.observable_grouping
)¶
Module for conducting Pauli observable grouping.
- observables_restricted_to_subsystem(qubits, global_observables, /)[source]¶
Restrict each observable to its support on a given subsystem.
A
PauliList
will be returned if aPauliList
is provided; otherwise, alist[Pauli]
will be returned.Any phase information will be discarded, consistent with the standard behavior when slicing a Pauli.
- Parameters:
qubits (Sequence[int]) – The qubits in a subsystem
global_observables (Sequence[Pauli] | PauliList) – The list of observables
- Return type:
list[Pauli] | PauliList
- Returns:
Each
Pauli
restricted to the subsystem.
>>> observables_restricted_to_subsystem([1, 3], PauliList(["IXYZ", "iZZXX"])) PauliList(['IY', 'ZX'])
- class CommutingObservableGroup(general_observable, commuting_observables)[source]¶
Bases:
object
Set of mutually qubit-wise commuting observables.
-
general_observable:
Pauli
¶ A single Pauli string that contains all qubit-wise measurements needed to measure everything in
commuting_observables
.
-
general_observable:
- class ObservableCollection(observables, /)[source]¶
Bases:
object
Collection of observables organized for efficient taking of measurements.
The observables are automatically organized into sets of mutually qubit-wise commuting observables, each represented by a
CommutingObservableGroup
.Assign member variables.
- Parameters:
observables (PauliList | Iterable[Pauli]) – Observables of interest
- static construct_general_observables(commuting_subobservables, /)[source]¶
Construct the most general observable from each set of mutually commuting observables.
In special cases, advanced users may want to subclass and override this
staticmethod
in order to measure additional qubits than the default for each general observable.
- property groups: list[CommutingObservableGroup]¶
List of
CommutingObservableGroup
s which, together, contain all desired observables.
- property lookup: dict[Pauli, list[tuple[int, int]]]¶
Get dict which maps each
Pauli
observable to a list of indices,(i, j)
, to commuting observables ingroups
.For each element of the list, it means that the
Pauli
is given by thej
-th commuting observable in thei
-th group.This list will be of length 1 at minimum, but may potentially be longer if multiple
CommutingObservableGroup
objects are compatible with the givenPauli
.