Skip to content

Commit

Permalink
fix probabilistic tests and correction
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone-Bordoni committed Mar 7, 2024
1 parent 381bfbe commit 37f1be1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/qibo/backends/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ def calculate_hamiltonian_state_product(self, matrix, state):
def test_regressions(self, name):
if name == "test_measurementresult_apply_bitflips":
return [
[4, 0, 0, 1, 0, 2, 2, 4, 4, 0],
[4, 0, 0, 1, 0, 2, 2, 4, 4, 0],
[4, 0, 0, 1, 0, 0, 0, 4, 4, 0],
[4, 0, 0, 0, 0, 0, 0, 4, 4, 0],
[4, 0, 0, 1, 0, 0, 1, 0, 0, 0],
[0, 1, 1, 2, 1, 1, 4, 0, 0, 4],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 4, 0, 0, 0, 4],
]
elif name == "test_probabilistic_measurement":
if "GPU" in self.device: # pragma: no cover
Expand All @@ -223,6 +223,6 @@ def test_regressions(self, name):
elif name == "test_post_measurement_bitflips_on_circuit":
return [
{5: 30},
{5: 16, 7: 10, 6: 2, 3: 1, 4: 1},
{3: 6, 5: 6, 7: 5, 2: 4, 4: 3, 0: 2, 1: 2, 6: 2},
{5: 12, 7: 6, 4: 6, 1: 5, 6: 1},
{3: 7, 6: 4, 2: 4, 7: 4, 0: 4, 5: 3, 4: 2, 1: 2},
]
4 changes: 1 addition & 3 deletions tests/test_measurements_probabilistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ def test_measurementresult_apply_bitflips(backend, i, p0, p1):

c = models.Circuit(3)
c.add(gates.M(*range(3)))
state = np.zeros(8)
state[0] = 1.0
state = backend.cast(state)
state = backend.zero_state(8)
result = CircuitResult(state, c.measurements, backend)
result._samples = backend.cast(np.zeros((10, 3)), dtype="int32")
backend.set_seed(123)
Expand Down

0 comments on commit 37f1be1

Please sign in to comment.