Skip to content

Conversation

@arnavk23
Copy link

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)
  • Maintains full backward compatibility with QPY serialization and synthesis code

Testing:

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

Documentation:

  • Added release note via reno in releasenotes/notes/allow-pauli-accessor-15468.yaml
  • Public method includes comprehensive docstring for API documentation

Verification:

  • Tested locally: 31/31 PauliProductMeasurement tests pass
  • No changes to serialization, synthesis, or other code paths

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

Pull Request Test Coverage Report for Build 20375939943

Details

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

Files with Coverage Reduction New Missed Lines %
crates/circuit/src/parameter/parameter_expression.rs 1 82.3%
crates/qasm2/src/lex.rs 1 93.32%
crates/circuit/src/parameter/symbol_expr.rs 10 72.9%
Totals Coverage Status
Change from base Build 20366546417: 0.01%
Covered Lines: 96731
Relevant Lines: 109519

💛 - Coveralls

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

4 participants