Skip to content

Postselection, point 4 of #336 - #340

Merged
tatopenn-cell merged 13 commits into
mainfrom
postselection
Oct 2, 2026
Merged

tatopenn-cell merged 13 commits into
mainfrom
postselection

Conversation

@tatopenn-cell

Copy link
Copy Markdown
Owner

Point 4 of #336. Builds on #337, #338, #339 (contains their commits until they are merged).

  • postselect(sv, n, qubit, state): projects the qubit onto state ('0', '1', '+', '-', '+i', '-i') and renormalises; returns (state, probability); raises if the probability is zero. Definition: Aaronson, quant-ph/0412187, Definition 1.

Tests: '0'/'1' against keeping the matching amplitudes; the other four against the basis-change circuit (h, or sdg+h) with postselection on |0⟩/|1⟩ and the inverse change; mid-circuit postselection against copying the qubit with cx into a fresh ancilla and postselecting it at the end (Aaronson, Sect. 3).

Also in #337 (merged forward here): arithmetic functions now call ensure_x64() before building JAX arrays, so results stay complex128.

Docs: new page api/postselect.md, nav entry, README line.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.63014% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dense_evolution/circuits/arithmetic.py 99.14% 1 Missing ⚠️
dense_evolution/circuits/postselect.py 96.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tatopenn-cell
tatopenn-cell merged commit ea666ac into main Oct 2, 2026
9 checks passed
@tatopenn-cell
tatopenn-cell deleted the postselection branch October 2, 2026 13:36
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.

1 participant