From 72ba4165be437e622b983a170ec05871c8c8b80a Mon Sep 17 00:00:00 2001 From: Matteo Robbiati <62071516+MatteoRobbiati@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:11:59 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: BrunoLiegiBastonLiegi <45011234+BrunoLiegiBastonLiegi@users.noreply.github.com> --- src/qibotn/backends/__init__.py | 2 +- src/qibotn/backends/qmatchatea.py | 2 +- src/qibotn/result.py | 15 +++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qibotn/backends/__init__.py b/src/qibotn/backends/__init__.py index 624ed62..b1b13a4 100644 --- a/src/qibotn/backends/__init__.py +++ b/src/qibotn/backends/__init__.py @@ -35,7 +35,7 @@ class MetaBackend: else: raise_error( NotImplementedError, - f"Unsupported platform {platform}, please pick one in (`cutensornet`, `qutensornet`, `qmatchatea`)", + f"Unsupported platform {platform}, please pick one in {PLATFORMS}", ) def list_available(self) -> dict: diff --git a/src/qibotn/backends/qmatchatea.py b/src/qibotn/backends/qmatchatea.py index 9353a34..ddeb0b8 100644 --- a/src/qibotn/backends/qmatchatea.py +++ b/src/qibotn/backends/qmatchatea.py @@ -19,7 +19,7 @@ class QMatchaTeaBackend(QibotnBackend): def __init__(self): super().__init__() - self.name = "qiboml" + self.name = "qibotn" self.platform = "qmatchatea" # Set default configurations diff --git a/src/qibotn/result.py b/src/qibotn/result.py index b6d0b52..90a164c 100644 --- a/src/qibotn/result.py +++ b/src/qibotn/result.py @@ -26,10 +26,10 @@ class TensorNetworkResult: """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]: + for bitstring, prob in self.measured_probabilities[self.prob_type].items(): measured_probabilities[self.prob_type][bitstring] = ( - self.measured_probabilities[self.prob_type][bitstring][1] - - self.measured_probabilities[self.prob_type][bitstring][0] + prob[1] + - prob[0] ) probabilities = measured_probabilities[self.prob_type] else: @@ -50,8 +50,7 @@ class TensorNetworkResult: """Return the statevector if the number of qubits is less than 30.""" if self.nqubits < 20: return self.statevector - else: - raise_error( - NotImplementedError, - f"Tensor network simulation cannot be used to reconstruct statevector for >= 30 .", - ) + raise_error( + NotImplementedError, + f"Tensor network simulation cannot be used to reconstruct statevector for >= 30 .", + )