Skip to content

Commit

Permalink
fix: expectation decoding test
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoRobbiati committed Oct 22, 2024
1 parent 309a26a commit 5871804
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 @@ -25,8 +25,8 @@ def test_state_layer(backend):
backend.assert_allclose(real + 1j * im, backend.execute_circuit(c).state())


@pytest.mark.parametrize("analytic", [True, False])
def test_expectation_layer(backend, analytic):
@pytest.mark.parametrize("nshots", [None, 10000])
def test_expectation_layer(backend, nshots):
backend.set_seed(42)
rng = np.random.default_rng(42)
nqubits = 5
Expand All @@ -43,14 +43,13 @@ def test_expectation_layer(backend, analytic):
layer = dec.Expectation(
nqubits,
observable=observable,
nshots=int(1e5),
nshots=nshots,
backend=backend,
analytic=analytic,
)
layer_expv = layer(c)
expv = (
observable.expectation(backend.execute_circuit(c).state())
if analytic
if nshots is None
else observable.expectation_from_samples(
layer.circuit.measurements[0].result.frequencies()
)
Expand Down

0 comments on commit 5871804

Please sign in to comment.