From a6aa4d1968aa9180c3d0e1b5c2d1de4e88237536 Mon Sep 17 00:00:00 2001 From: Pablo Andres-Martinez Date: Wed, 3 Apr 2024 08:01:10 -0700 Subject: [PATCH] Now checking if chi is set to the default 'essentially unbounded' value; if so, do not raise error if non-default truncation fidelity is set. --- pytket/extensions/cutensornet/structured_state/general.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytket/extensions/cutensornet/structured_state/general.py b/pytket/extensions/cutensornet/structured_state/general.py index 25d65876..fc862dc2 100644 --- a/pytket/extensions/cutensornet/structured_state/general.py +++ b/pytket/extensions/cutensornet/structured_state/general.py @@ -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 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