Skip to content

Add fidelity and isclose methods to Statevec#433

Merged
emlynsg merged 3 commits intoTeamGraphix:masterfrom
CodeMaverick2:feat/statevec-fidelity-isclose
Feb 17, 2026
Merged

Add fidelity and isclose methods to Statevec#433
emlynsg merged 3 commits intoTeamGraphix:masterfrom
CodeMaverick2:feat/statevec-fidelity-isclose

Conversation

@CodeMaverick2
Copy link
Contributor

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run nox)
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.
  • Format added code by ruff
    • See CONTRIBUTING.md for more details
  • Make sure the checks (github actions) pass.

Then, please fill in below:

Context (if applicable):

  • Tests across the codebase manually compute pure-state fidelity with np.abs(np.dot(state.flatten().conjugate(), state2.flatten())) == pytest.approx(1) in ~68 places.

Description of the change:

  • Add Statevec.fidelity(other) computing |⟨ψ₁|ψ₂⟩|² and Statevec.isclose(other) checking equality up to global phase
  • Replace ~68 manual inner-product assertions across 11 test files with isclose
  • Add 9 unit tests for the new methods
Screenshot 2026-02-14 210649

Related issue:
Closes #386

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.74%. Comparing base (c1f689d) to head (4cb7535).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #433   +/-   ##
=======================================
  Coverage   88.73%   88.74%           
=======================================
  Files          44       44           
  Lines        6303     6308    +5     
=======================================
+ Hits         5593     5598    +5     
  Misses        710      710           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@emlynsg emlynsg left a comment

Choose a reason for hiding this comment

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

Great work, thank you very much.

We at TeamGraphix have a 2 approval policy, so when a second maintainer approves this PR we are happy to merge it and close the issue with you allocated.

@CodeMaverick2
Copy link
Contributor Author

Great work, thank you very much.

We at TeamGraphix have a 2 approval policy, so when a second maintainer approves this PR we are happy to merge it and close the issue with you allocated.

@emlynsg
Thanks for the approval!
Since TeamGraphix follows a 2-approval policy, could you please tag another maintainer to take a look at the PR so we can move it forward?

Copy link
Contributor

@matulni matulni left a comment

Choose a reason for hiding this comment

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

Hi @CodeMaverick2, thanks for your contribution and welcome to the project!

PR looks good, I made a couple of small comments and I'll be happy to approve (and assign you the issue) once they've been addressed. Please, don't forget to update the CHANGELOG and resolve any conflicts arising from recent merges.

Thanks!

@CodeMaverick2 CodeMaverick2 force-pushed the feat/statevec-fidelity-isclose branch from cec6272 to 4cb7535 Compare February 17, 2026 11:15
Copy link
Contributor

@matulni matulni left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

@emlynsg emlynsg merged commit 01ea6cf into TeamGraphix:master Feb 17, 2026
38 of 39 checks passed
@CodeMaverick2 CodeMaverick2 deleted the feat/statevec-fidelity-isclose branch February 17, 2026 16:42
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.

New method fidelity for Statevec

3 participants