Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

garrison
Copy link
Member

@garrison garrison commented May 8, 2024

  • mention that phases are discarded
  • add list[Pauli] test case

@garrison garrison added documentation Improvements or additions to documentation tests Related to tests labels May 8, 2024
@coveralls
Copy link

coveralls commented May 8, 2024

Pull Request Test Coverage Report for Build 9104482645

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.472%

Totals Coverage Status
Change from base Build 9104465513: 0.0%
Covered Lines: 3500
Relevant Lines: 3666

💛 - 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.
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

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),
Copy link
Collaborator

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 👀

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation tests Related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants