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

[bugfix] Default value of chi causes an error when state is copied #93

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

PabloAndresCQ
Copy link
Collaborator

@PabloAndresCQ PabloAndresCQ commented Apr 3, 2024

Description

Users can only choose whether to use a bounded chi or a bounded truncation_fidelity when using simulation methods from structured_state. If both are bounded by the user, an error is raised.

However, internally, both of these are set to some default value when the user does not bound them. This caused the "user error" to be raised when copying a state with truncation_fidelity bounded by the user, because the initialiser of the copy would interpret that the default value of chi was also specified by the user. The fix I went for is to check whether the value of chi is the default one, before raising the error (something that was already done for truncation_fidelity.

Checklist

  • I have run the tests on a machine with GPUs.
  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

…ue; if so, do not raise error if non-default truncation fidelity is set.
@PabloAndresCQ PabloAndresCQ requested a review from cqc-melf April 3, 2024 15:11
if (
chi is not None
and chi < _CHI_LIMIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

You mean <= ?
And are you usually adding tests for bugfixes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, it should be <. If it's equal to the "default value" _CHI_LIMIT, then this condition must evaluate to false, so that the error is not raised.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, we usually add test for bugfixes when relevant (and easy). I'm happy to add one for this, since it satisfies both requirements :P

@PabloAndresCQ PabloAndresCQ requested a review from cqc-melf April 3, 2024 15:55
@PabloAndresCQ PabloAndresCQ merged commit 1ad0eb3 into develop Apr 3, 2024
6 checks passed
@PabloAndresCQ PabloAndresCQ deleted the bugfix/copy_state_set_chi branch April 3, 2024 16:09
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.

2 participants