Skip to content

feature: add PauliString sums#1283

Open
dorakingx wants to merge 2 commits into
amazon-braket:mainfrom
dorakingx:unitaryhack/pauli-string-sums
Open

feature: add PauliString sums#1283
dorakingx wants to merge 2 commits into
amazon-braket:mainfrom
dorakingx:unitaryhack/pauli-string-sums

Conversation

@dorakingx

Copy link
Copy Markdown

Closes #1256.

Summary

  • Adds PauliSum, a weighted container for PauliString terms.
  • Supports Pauli string addition/subtraction, scalar multiplication, distributed multiplication by Pauli strings or other Pauli sums, indexing, membership checks, and commuting checks.
  • Adds conversion helpers to and from weighted term lists and Braket Observable.Sum objects built from Pauli observables.
  • Re-exports PauliSum from braket.quantum_information.

Validation

  • uv run pytest test/unit_tests/braket/quantum_information/test_pauli_string.py -q
  • uvx ruff check src/braket/quantum_information/pauli_string.py src/braket/quantum_information/__init__.py
  • uvx ruff format --check src/braket/quantum_information/pauli_string.py src/braket/quantum_information/__init__.py test/unit_tests/braket/quantum_information/test_pauli_string.py

AI assistance disclosure: I used Codex as a coding assistant, then inspected the generated changes and ran the validation commands above.

@dorakingx dorakingx marked this pull request as ready for review June 5, 2026 01:56
@dorakingx dorakingx requested a review from a team as a code owner June 5, 2026 01:56
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a5ee47d) to head (444efa5).

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #1283    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          169       169            
  Lines        10963     11109   +146     
  Branches      1412      1439    +27     
==========================================
+ Hits         10963     11109   +146     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dorakingx

Copy link
Copy Markdown
Author

I pushed an update to address the Codecov failures.

Changes:

  • Added tests for PauliSum edge cases and error paths that Codecov reported as missing.
  • Added support for PauliString * PauliSum so multiplication distributes consistently in both directions.

Local validation:

uv run python -m coverage erase
PYTEST_ADDOPTS="" uv run python -m coverage run -m pytest -o addopts="" test/unit_tests/braket/quantum_information/test_pauli_string.py -q
uv run python -m coverage report -m src/braket/quantum_information/pauli_string.py

This now reports src/braket/quantum_information/pauli_string.py at 100% coverage locally.

I also ran:

uvx tox -e linters_check
uvx tox -e unit-tests -- test/unit_tests/braket/quantum_information/test_pauli_string.py -q

The targeted tox unit-test run passed with 65 passed and 32 xfailed.

@sesmart sesmart requested a review from speller26 June 8, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for Sums of PauliStrings

1 participant