From 0f3f836cbd2a06c056dbef4a43728ab78bd97425 Mon Sep 17 00:00:00 2001 From: Jake Arkinstall <65358059+jake-arkinstall@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:14:52 +0100 Subject: [PATCH] Convert isclose usage to a lower bound check (addressing #135) required for nix tests to pass --- tests/test_structured_state.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_structured_state.py b/tests/test_structured_state.py index d3d78d61..ebb3cc09 100644 --- a/tests/test_structured_state.py +++ b/tests/test_structured_state.py @@ -544,7 +544,7 @@ def test_circ_approx_explicit_mps(circuit: Circuit) -> None: SimulationAlgorithm.MPSxGate, cfg, ) - assert np.isclose(mps_gate.get_fidelity(), 0.4, atol=1e-1) + assert mps_gate.get_fidelity() >= 0.3 assert mps_gate.is_valid() assert np.isclose(mps_gate.vdot(mps_gate), 1.0, atol=cfg._atol) @@ -555,7 +555,7 @@ def test_circ_approx_explicit_mps(circuit: Circuit) -> None: SimulationAlgorithm.MPSxMPO, cfg, ) - assert np.isclose(mps_mpo.get_fidelity(), 0.6, atol=1e-1) + assert mps_mpo.get_fidelity() >= 0.5 assert mps_mpo.is_valid() assert np.isclose(mps_mpo.vdot(mps_mpo), 1.0, atol=cfg._atol) @@ -563,13 +563,13 @@ def test_circ_approx_explicit_mps(circuit: Circuit) -> None: # Check for MPSxGate cfg = Config(chi=8, leaf_size=4, float_precision=np.float32) mps_gate = simulate(libhandle, circuit, SimulationAlgorithm.MPSxGate, cfg) - assert np.isclose(mps_gate.get_fidelity(), 0.03, atol=1e-2) + assert mps_gate.get_fidelity() >= 0.02 assert mps_gate.is_valid() assert np.isclose(mps_gate.vdot(mps_gate), 1.0, atol=cfg._atol) # Check for MPSxMPO mps_mpo = simulate(libhandle, circuit, SimulationAlgorithm.MPSxMPO, cfg) - assert np.isclose(mps_mpo.get_fidelity(), 0.05, atol=1e-2) + assert mps_mpo.get_fidelity() >= 0.04 assert mps_mpo.is_valid() assert np.isclose(mps_mpo.vdot(mps_mpo), 1.0, atol=cfg._atol) @@ -588,7 +588,7 @@ def test_circ_approx_explicit_ttn(circuit: Circuit) -> None: # Check for TTNxGate cfg = Config(truncation_fidelity=0.99, leaf_size=3, float_precision=np.float32) ttn_gate = simulate(libhandle, circuit, SimulationAlgorithm.TTNxGate, cfg) - assert np.isclose(ttn_gate.get_fidelity(), 0.751, atol=1e-3) + assert ttn_gate.get_fidelity() >= 0.750 assert ttn_gate.is_valid() assert np.isclose(ttn_gate.vdot(ttn_gate), 1.0, atol=cfg._atol) @@ -596,7 +596,7 @@ def test_circ_approx_explicit_ttn(circuit: Circuit) -> None: # Check for TTNxGate cfg = Config(chi=120, leaf_size=3, float_precision=np.float32) ttn_gate = simulate(libhandle, circuit, SimulationAlgorithm.TTNxGate, cfg) - assert np.isclose(ttn_gate.get_fidelity(), 0.854, atol=1e-3) + assert ttn_gate.get_fidelity() >= 0.853 assert ttn_gate.is_valid() assert np.isclose(ttn_gate.vdot(ttn_gate), 1.0, atol=cfg._atol)