fix: probabilities method in result class
This commit is contained in:
@@ -76,7 +76,7 @@ class QMatchaTeaBackend(QibotnBackend):
|
||||
circuit,
|
||||
initial_state=None,
|
||||
nshots=None,
|
||||
prob_type="U",
|
||||
prob_type=None,
|
||||
return_array=False,
|
||||
**prob_kwargs,
|
||||
):
|
||||
@@ -123,6 +123,10 @@ class QMatchaTeaBackend(QibotnBackend):
|
||||
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()
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from copy import deepcopy
|
||||
from dataclasses import dataclass
|
||||
from typing import Union
|
||||
|
||||
@@ -24,12 +25,13 @@ class TensorNetworkResult:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user