Skip to content

Commit

Permalink
test mps.compute_local_expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Oct 18, 2024
1 parent d57eb53 commit f911c59
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_tensor/test_tensor_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,16 @@ def test_sample_seed(self):
]
assert len(set(configs)) > 1

def test_compute_local_expectation(self):
psi = qtn.MPS_rand_state(10, 7, dtype="complex128")
terms = {(i, i + 1): qu.rand_herm(4) for i in range(9)}

ex = psi.compute_local_expectation_exact(terms)
xa = psi.compute_local_expectation(terms, method="canonical")
assert xa == pytest.approx(ex)
xb = psi.compute_local_expectation(terms, method="envs")
assert xb == pytest.approx(ex)


class TestMatrixProductOperator:
@pytest.mark.parametrize("cyclic", [False, True])
Expand Down

0 comments on commit f911c59

Please sign in to comment.