From 39b00931e6b6f2814cc666b7af75bbc2ce0e2412 Mon Sep 17 00:00:00 2001 From: "Davide Gessa (dakk)" Date: Fri, 27 Oct 2023 12:48:03 +0200 Subject: [PATCH] fix linter --- examples/groover_hash_collision.py | 4 ++-- qlasskit/algorithms/groover.py | 1 - qlasskit/algorithms/qalgorithm.py | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/groover_hash_collision.py b/examples/groover_hash_collision.py index d7475e1a..0cc2dfcb 100644 --- a/examples/groover_hash_collision.py +++ b/examples/groover_hash_collision.py @@ -8,7 +8,7 @@ def qiskit_simulate(qc): qc.measure_all() - print(qc.draw('text')) + print(qc.draw("text")) simulator = Aer.get_backend("aer_simulator") circ = transpile(qc, simulator) @@ -55,5 +55,5 @@ def hash(k: Qint4) -> Qint4: plt.show() -print(hash.circuit().export("circuit", 'qiskit').draw('text')) +print(hash.circuit().export("circuit", "qiskit").draw("text")) # plt.show() diff --git a/qlasskit/algorithms/groover.py b/qlasskit/algorithms/groover.py index 5a863f25..09cf2154 100644 --- a/qlasskit/algorithms/groover.py +++ b/qlasskit/algorithms/groover.py @@ -97,7 +97,6 @@ def oracle_outer(v: {argt_name}) -> bool: ] self.qc.h(oracle_qc["_ret_phased"]) - for i in range(n_iterations): self.qc.barrier(label=f"g{i}") # self.qc.barrier(label=f"orac_{i}") diff --git a/qlasskit/algorithms/qalgorithm.py b/qlasskit/algorithms/qalgorithm.py index f612a804..b8a4eae8 100644 --- a/qlasskit/algorithms/qalgorithm.py +++ b/qlasskit/algorithms/qalgorithm.py @@ -50,15 +50,15 @@ def out_qubits(self) -> List[int]: def interpet_counts(self, counts: Dict[str, int]) -> Dict[Any, int]: """Interpet data inside a circuit counts dict""" - l = [(self.interpret_outcome(e), c) for (e, c) in counts.items()] - d = {} - for (e, c) in l: + outcomes = [(self.interpret_outcome(e), c) for (e, c) in counts.items()] + int_counts: Dict[Any, int] = {} + for e, c in outcomes: inter = self.interpret_outcome(e) - if inter in d: - d[inter] += c + if inter in int_counts: + int_counts[inter] += c else: - d[inter] = c - return d + int_counts[inter] = c + return int_counts def export(self, framework: SupportedFramework = "qiskit") -> Any: """Export the algorithm to a supported framework"""