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
PauliListwill be returned if aPauliListis 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
Paulirestricted to the subsystem.
>>> observables_restricted_to_subsystem([1, 3], PauliList(["IXYZ", "iZZXX"])) PauliList(['IY', 'ZX'])
- class CommutingObservableGroup(general_observable, commuting_observables)[source]¶
Bases:
objectSet 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:
objectCollection 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
staticmethodin order to measure additional qubits than the default for each general observable.
- property groups: list[CommutingObservableGroup]¶
List of
CommutingObservableGroups which, together, contain all desired observables.
- property lookup: dict[Pauli, list[tuple[int, int]]]¶
Get dict which maps each
Pauliobservable to a list of indices,(i, j), to commuting observables ingroups.For each element of the list, it means that the
Pauliis 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
CommutingObservableGroupobjects are compatible with the givenPauli.