Skip to content

Fix Kraus coefficients in pauli_channel - #659

Open
chenyangsu wants to merge 1 commit into
TeamGraphix:masterfrom
chenyangsu:fix/pauli-channel-kraus-coefs
Open

chenyangsu wants to merge 1 commit into
TeamGraphix:masterfrom
chenyangsu:fix/pauli-channel-kraus-coefs

Conversation

@chenyangsu

Copy link
Copy Markdown

Context (if applicable):
pauli_channel(0.1, 0.1, 0.1) raises ValueError: The specified channel is not normalized. because it passes np.sqrt(1 - p_i) for Ops.I and divides each Pauli probability by 3.0. At pauli_channel(0.25, 0.25, 0.25), normalization passes with squared coefficients [0.75, 0.0833, 0.0833, 0.0833] rather than [0.25, 0.25, 0.25, 0.25].

Description of the change:
Could we use np.sqrt(p_i) for Ops.I and np.sqrt(px), np.sqrt(py), np.sqrt(pz) for X, Y, Z, with check_probability on each input? Happy to skip check_probability if you prefer.

Related issue:
None.

Testing: pytest tests/test_kraus.py -> 9 passed (new test_pauli_channel fails on master), plus 130 density matrix tests, ruff, mypy, and pyright.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (8d433df) to head (d4f4b31).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #659      +/-   ##
==========================================
+ Coverage   90.05%   90.10%   +0.05%     
==========================================
  Files          49       49              
  Lines        8524     8529       +5     
==========================================
+ Hits         7676     7685       +9     
+ Misses        848      844       -4     

☔ 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.

@matulni matulni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me! Project's policy is to have two maintainer approval before merging, so let's wait for a second approval.

Thanks for the bug-fix!!

@matulni
matulni requested a review from mgarnier59 December 3, 2026 16:31

This branch has not been deployed

No deployments
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.

2 participants