Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to control slackness in physicality conditions. #524

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

arsalan-motamedi
Copy link
Collaborator

Context:
Currently, the tolerance for channel CPTP conditions, density matrix positivity and trace conditions, and pure state norm conditions use settings.ATOL to control their slackness. This PR allows to use arbitrary slackness for them.

Description of the Change:
Introduced new variable atol: float = settings.ATOL which is to control this slackness in all physicality conditions including is_CP, is_TP, and is_physical for Channels, and is_positive and is_physical for DMs, and finally, is_physical for Kets.

Benefits:
Will be convenient to set the slackness. Also, is helpful in some tests.

Possible Drawbacks:
None.
Related GitHub Issues:
None.

@arsalan-motamedi arsalan-motamedi added the no changelog Pull request does not require a CHANGELOG entry label Nov 15, 2024
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.80%. Comparing base (f3c226d) to head (778ddc1).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #524      +/-   ##
===========================================
- Coverage    89.81%   89.80%   -0.02%     
===========================================
  Files           93       93              
  Lines         6098     6092       -6     
===========================================
- Hits          5477     5471       -6     
  Misses         621      621              
Files with missing lines Coverage Δ
mrmustard/lab_dev/states/dm.py 95.59% <100.00%> (-0.06%) ⬇️
mrmustard/lab_dev/states/ket.py 98.58% <100.00%> (-0.01%) ⬇️
mrmustard/lab_dev/transformations/base.py 99.41% <100.00%> (-0.02%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3c226d...778ddc1. Read the comment docs.

@@ -49,10 +49,12 @@ class DM(State):

short_name = "DM"

@property
def is_positive(self) -> bool:
def is_positive(self, atol: float = settings.ATOL) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than adding a parameter what if instead we encouraged users to use

with settings(ATOL=1e-8):
     ...

Of course we would then have to make that clear in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog Pull request does not require a CHANGELOG entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants