Skip to content

Conversation

@arnavk23
Copy link
Contributor

@arnavk23 arnavk23 commented Dec 19, 2025

Summary

Add a public accessor method pauli() to PauliProductMeasurement to expose the underlying Pauli object measured by the instruction.

Details and comments

This PR implements the feature requested in #15468 by adding a public pauli() method to the PauliProductMeasurement class.

Implementation:

  • Added pauli() -> Pauli method that reconstructs the Pauli product from internal z/x/phase components
  • Returns the full Pauli including global phase (+1 or -1)
  • Leverages existing internal storage (_pauli_z, _pauli_x, _pauli_phase)

Testing:

  • Added test_pauli_accessor() unit test in test/python/circuit/library/test_ppm.py
  • Verifies that PauliProductMeasurement(Pauli("-XZ")).pauli() == Pauli("-XZ")

Documentation:

  • Added release note via reno in releasenotes/notes/allow-pauli-accessor-15468.yaml

Verification:

  • Tested locally: 31/31 PauliProductMeasurement tests pass

Fixes #15468

Add a public accessor method pauli() to PauliProductMeasurement to expose the
underlying Pauli object that the instruction measures. This addresses issue Qiskit#15468.

- Added pauli() method returning Pauli with z, x, and phase components
- Added unit test test_pauli_accessor to verify accessor returns original Pauli
- Added release note documenting the new feature

The accessor uses the existing internal _pauli_z, _pauli_x, and _pauli_phase
attributes to reconstruct the full Pauli object, maintaining compatibility with
existing serialization and synthesis code paths.
@arnavk23 arnavk23 requested a review from a team as a code owner December 19, 2025 16:23
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Dec 19, 2025
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

@ShellyGarion ShellyGarion added mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library Changelog: New Feature Include in the "Added" section of the changelog labels Dec 21, 2025
@coveralls
Copy link

coveralls commented Dec 21, 2025

Pull Request Test Coverage Report for Build 20462188496

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 10 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.01%) to 88.321%

Files with Coverage Reduction New Missed Lines %
crates/circuit/src/parameter/parameter_expression.rs 1 82.3%
crates/qasm2/src/lex.rs 4 91.52%
crates/circuit/src/parameter/symbol_expr.rs 5 73.1%
Totals Coverage Status
Change from base Build 20366546417: 0.01%
Covered Lines: 96728
Relevant Lines: 109519

💛 - Coveralls

@arnavk23 arnavk23 requested a review from Cryoris December 23, 2025 13:36
@arnavk23
Copy link
Contributor Author

arnavk23 commented Jan 1, 2026

@Cryoris all test are passing and added your review suggestions.

Copy link
Collaborator

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the addition!

@Cryoris Cryoris added this pull request to the merge queue Jan 5, 2026
Merged via the queue into Qiskit:main with commit 6c20d76 Jan 5, 2026
23 checks passed
@arnavk23 arnavk23 deleted the add-pauli-accessor-15468 branch January 5, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: New Feature Include in the "Added" section of the changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow access to Pauli data in PauliProductMeasurement

5 participants