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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pytket/extensions/cutensornet/structured_state/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ def __init__(
ValueError: If the value of ``chi`` is set below 2.
ValueError: If the value of ``truncation_fidelity`` is not in [0,1].
"""
_CHI_LIMIT = 2**60
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

and truncation_fidelity is not None
and truncation_fidelity != 1.0
):
raise ValueError("Cannot fix both chi and truncation_fidelity.")
if chi is None:
chi = 2**60 # In practice, this is like having it be unbounded
chi = _CHI_LIMIT # In practice, this is like having it be unbounded
if truncation_fidelity is None:
truncation_fidelity = 1

Expand Down