-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs and tests of observables_restricted_to_subsystem
#579
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 9104482645Details
💛 - Coveralls |
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could mention the other function(s) that has this behavior, since a user may not immediately know what all this "slicing a Pauli" means exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of what I mean that the phase gets discarded:
>>> from qiskit.quantum_info import Pauli
>>> Pauli("iXZX")[:2]
Pauli('ZX')
It's the act of slicing, not really a function, but I will try to think of a better explanation that doesn't require somebody to know Python or programming jargon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh I see. Actual Python slicing. No, this is fine. Thanks
@@ -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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So flipping the order of IDs, flips the order of the Paulis..I'm sure this is intended, but worth staring at for a second 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wanted to make sure there was an actual test where things are meant to get re-ordered.
list[Pauli]
test case