From 71753689ec7d72aa5ed3f513069d6644cb977277 Mon Sep 17 00:00:00 2001 From: Joe Schulte Date: Sat, 20 Apr 2024 21:09:01 -0400 Subject: [PATCH] removing unnecessary-list-index-lookup from lint exclusions and updates (#12285) --- pyproject.toml | 1 - qiskit/transpiler/passes/routing/stochastic_swap.py | 2 +- test/python/compiler/test_transpiler.py | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b48b5c6c28e5..0d99f9256df3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -231,7 +231,6 @@ disable = [ "unnecessary-dict-index-lookup", "unnecessary-dunder-call", "unnecessary-lambda-assignment", - "unnecessary-list-index-lookup", "unspecified-encoding", "unsupported-assignment-operation", "use-dict-literal", diff --git a/qiskit/transpiler/passes/routing/stochastic_swap.py b/qiskit/transpiler/passes/routing/stochastic_swap.py index 105ed9d23a5a..3b80bf7b31af 100644 --- a/qiskit/transpiler/passes/routing/stochastic_swap.py +++ b/qiskit/transpiler/passes/routing/stochastic_swap.py @@ -323,7 +323,7 @@ def _mapper(self, circuit_graph, coupling_graph, trials=20): # Update the DAG if not self.fake_run: self._layer_update( - dagcircuit_output, layerlist[i], best_layout, best_depth, best_circuit + dagcircuit_output, layer, best_layout, best_depth, best_circuit ) continue diff --git a/test/python/compiler/test_transpiler.py b/test/python/compiler/test_transpiler.py index 6eb54ddc4be9..d4e19da541a0 100644 --- a/test/python/compiler/test_transpiler.py +++ b/test/python/compiler/test_transpiler.py @@ -294,10 +294,10 @@ def test_transpile_qft_grid(self): qr = QuantumRegister(8) circuit = QuantumCircuit(qr) - for i, _ in enumerate(qr): + for i, q in enumerate(qr): for j in range(i): - circuit.cp(math.pi / float(2 ** (i - j)), qr[i], qr[j]) - circuit.h(qr[i]) + circuit.cp(math.pi / float(2 ** (i - j)), q, qr[j]) + circuit.h(q) new_circuit = transpile( circuit, basis_gates=basis_gates, coupling_map=MELBOURNE_CMAP, seed_transpiler=42