Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

change the purity calculation for gaussian state#747

Open
sylviemonet wants to merge 1 commit intomasterfrom
fixpurityforgaussian
Open

change the purity calculation for gaussian state#747
sylviemonet wants to merge 1 commit intomasterfrom
fixpurityforgaussian

Conversation

@sylviemonet
Copy link
Copy Markdown
Contributor

@sylviemonet sylviemonet commented May 14, 2024

Context: The purity calculation for gaussian state depends on the precision in SF, however, in some cases, this value can be small but the tolerance is not enough small to detect it, hence, the state which should be mixed become a "pure" tag in the gaussian backend calculation.

Description of the Change: This PR fix the calculation from a - b <tol into a/b == 1.0 as the condition.

Benefits:

Possible Drawbacks: I believe that when we set of the calculation in the way a - b <tol, there must be some considerations behind. So it may be not a good solution for all library.

Related GitHub Issues: Issue 745

Comment on lines +1013 to +1014
np.abs(np.linalg.det(self._cov)) / (self._hbar / 2) ** (2 * self._modes)
== 1.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What about using np.isclose?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants