Skip to content

Commit

Permalink
fix: probabilities method in result class
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoRobbiati committed Feb 4, 2025
1 parent 8b7bb9e commit 65b60e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/qibotn/backends/qmatchatea.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def execute_circuit(
circuit,
initial_state=None,
nshots=None,
prob_type="U",
prob_type=None,
return_array=False,
**prob_kwargs,
):
Expand Down Expand Up @@ -123,6 +123,10 @@ def execute_circuit(
f"Backend {self.name}-{self.platform} currently does not support initial state.",
)

if prob_type == None:
prob_type = "U"
prob_kwargs = {"num_samples": 500}

# To be sure the setup is correct and no modifications have been done
self._setup_qmatchatea_backend()

Expand Down
6 changes: 4 additions & 2 deletions src/qibotn/result.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import deepcopy
from dataclasses import dataclass
from typing import Union

Expand All @@ -24,12 +25,13 @@ def __post_init__(self):
def probabilities(self):
"""Return calculated probabilities according to the given method."""
if self.prob_type == "U":
measured_probabilities = deepcopy(self.measured_probabilities)
for bitstring in self.measured_probabilities[self.prob_type]:
self.measured_probabilities[self.prob_type][bitstring] = (
measured_probabilities[self.prob_type][bitstring] = (
self.measured_probabilities[self.prob_type][bitstring][1]
- self.measured_probabilities[self.prob_type][bitstring][0]
)
probabilities = self.measured_probabilities[self.prob_type]
probabilities = measured_probabilities[self.prob_type]
else:
probabilities = self.measured_probabilities[self.prob_type]
return probabilities
Expand Down

0 comments on commit 65b60e0

Please sign in to comment.