fix: probabilities method in result class
This commit is contained in:
@@ -76,7 +76,7 @@ class QMatchaTeaBackend(QibotnBackend):
|
|||||||
circuit,
|
circuit,
|
||||||
initial_state=None,
|
initial_state=None,
|
||||||
nshots=None,
|
nshots=None,
|
||||||
prob_type="U",
|
prob_type=None,
|
||||||
return_array=False,
|
return_array=False,
|
||||||
**prob_kwargs,
|
**prob_kwargs,
|
||||||
):
|
):
|
||||||
@@ -123,6 +123,10 @@ class QMatchaTeaBackend(QibotnBackend):
|
|||||||
f"Backend {self.name}-{self.platform} currently does not support initial state.",
|
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
|
# To be sure the setup is correct and no modifications have been done
|
||||||
self._setup_qmatchatea_backend()
|
self._setup_qmatchatea_backend()
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from copy import deepcopy
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
@@ -24,12 +25,13 @@ class TensorNetworkResult:
|
|||||||
def probabilities(self):
|
def probabilities(self):
|
||||||
"""Return calculated probabilities according to the given method."""
|
"""Return calculated probabilities according to the given method."""
|
||||||
if self.prob_type == "U":
|
if self.prob_type == "U":
|
||||||
|
measured_probabilities = deepcopy(self.measured_probabilities)
|
||||||
for bitstring in self.measured_probabilities[self.prob_type]:
|
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][1]
|
||||||
- self.measured_probabilities[self.prob_type][bitstring][0]
|
- self.measured_probabilities[self.prob_type][bitstring][0]
|
||||||
)
|
)
|
||||||
probabilities = self.measured_probabilities[self.prob_type]
|
probabilities = measured_probabilities[self.prob_type]
|
||||||
else:
|
else:
|
||||||
probabilities = self.measured_probabilities[self.prob_type]
|
probabilities = self.measured_probabilities[self.prob_type]
|
||||||
return probabilities
|
return probabilities
|
||||||
|
|||||||
Reference in New Issue
Block a user