Skip to content

Commit

Permalink
Convert isclose usage to a lower bound check (addressing #135) requir…
Browse files Browse the repository at this point in the history
…ed for nix tests to pass
  • Loading branch information
jake-arkinstall committed Oct 23, 2024
1 parent 2f91dff commit 0f3f836
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/test_structured_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -555,21 +555,21 @@ 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)

# Fixed virtual bond dimension
# 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)

Expand All @@ -588,15 +588,15 @@ 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)

# Fixed virtual bond dimension
# 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)

Expand Down

0 comments on commit 0f3f836

Please sign in to comment.