Skip to content

Commit

Permalink
fix: trying to mitigate numerical instability
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Aug 3, 2024
1 parent 606cbb9 commit a44942e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/test_models_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ def test_expectation_layer(backend, analytic):
backend=backend,
analytic=analytic,
)
c_copy = c.copy()
c_copy.add(gates.M(*range(nqubits)))
layer_expv = layer(c)
expv = (
observable.expectation(backend.execute_circuit(c_copy).state())
observable.expectation(backend.execute_circuit(c).state())
if analytic
else observable.expectation_from_samples(
backend.execute_circuit(c_copy, nshots=int(1e5)).frequencies()
backend.execute_circuit(c + layer.circuit, nshots=int(1e5)).frequencies()
)
)
backend.assert_allclose(layer(c), expv, atol=1e-1)
backend.assert_allclose(layer_expv, expv, atol=1e-1)

0 comments on commit a44942e

Please sign in to comment.