Repository navigation
fix(matrix_props): scale purity bound by trace squared in is_k_incoherent - #2057
Merged
vprusso merged 1 commit intoDec 1, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
vprusso
approved these changes
Dec 1, 2026
vprusso
left a comment
Owner
There was a problem hiding this comment.
Thanks @chenyangsu. The k-incoherent set is a cone while purity scales quadratically, so scaling the bound by trace squared is the correct fix, and the trace > 0 guard keeps the shortcut from accepting non-PSD input. Merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For
rho = np.full((4, 4), 0.25),is_k_incoherent(0.5 * rho, 3)returnsTruewhileis_k_incoherent(rho, 3)returnsFalse, because the purity shortcut comparestrace(mat @ mat.conj().T)against1 / (d - 1)assuming unit trace. Comparing againsttrace(mat) ** 2 / (d - 1)for positive trace keeps the Johnston et al. (2022) Eq. (8) bound invariant under positive scaling. Happy to normalizematupfront instead if you prefer.Changes
trace(mat) ** 2inis_k_incoherent.test_is_k_incoherent.py.Checklist
rufffor errors related to code style and formatting.pytest.Testing:
pytest toqito/matrix_props/tests/test_is_k_incoherent.py-> 32 passed (new test fails on master for scales 0.1 and 0.5).pytest toqito/matrix_props/tests/-> 537 passed, 6 skipped.ruff check,ruff format --check, andty checkpassed.