Skip to content

Commit

Permalink
Improve docs and tests of observables_restricted_to_subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
garrison committed May 8, 2024
1 parent c75f5f5 commit 911187a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion circuit_knitting/utils/observable_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ def observables_restricted_to_subsystem(
A :class:`~qiskit.quantum_info.PauliList` will be returned if a :class:`~qiskit.quantum_info.PauliList` is provided; otherwise,
a ``list[Pauli]`` will be returned.
Any phase information will be discarded, consistent with the standard behavior when slicing a Pauli.
Args:
qubits: The qubits in a subsystem
global_observables: The list of observables
Returns:
Each :class:`~qiskit.quantum_info.Pauli` restricted to the subsystem.
>>> observables_restricted_to_subsystem([1, 3], PauliList(["IXYZ", "ZZXX"]))
>>> observables_restricted_to_subsystem([1, 3], PauliList(["IXYZ", "iZZXX"]))
PauliList(['IY', 'ZX'])
"""
Expand Down
5 changes: 5 additions & 0 deletions test/utils/test_observable_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def test_most_general_observable(self):
PauliList(["XX", "YY", "ZZ"]),
PauliList.from_symplectic(np.zeros((3, 0)), np.zeros((3, 0))),
),
(
(2, 1),
[Pauli("XYZ"), Pauli("iZYX"), Pauli("-ZXZ")],
[Pauli("YX"), Pauli("YZ"), Pauli("XZ")],
),
)
@unpack
def test_observables_restricted_to_subsystem(self, qubits, observables, expected):
Expand Down

0 comments on commit 911187a

Please sign in to comment.