From f19dc6ed1ecb1e624ba6c4bbc63f72c3d3f56f20 Mon Sep 17 00:00:00 2001 From: changsookim <> Date: Fri, 25 Oct 2024 11:31:04 +0400 Subject: [PATCH] fix: minor changes --- src/qibo/models/circuit.py | 3 +-- src/qibo/transpiler/optimizer.py | 6 +++--- src/qibo/transpiler/placer.py | 2 -- tests/test_transpiler_placer.py | 7 ------- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/qibo/models/circuit.py b/src/qibo/models/circuit.py index 48523eb6cf..08aa4e639d 100644 --- a/src/qibo/models/circuit.py +++ b/src/qibo/models/circuit.py @@ -407,8 +407,7 @@ def light_cone(self, *qubits): qubit_map = {q: i for i, q in enumerate(sorted(qubits))} kwargs = dict(self.init_kwargs) kwargs["nqubits"] = len(qubits) - new_wire_names = [self.wire_names[q] for q in list(sorted(qubits))] - kwargs["wire_names"] = new_wire_names + kwargs["wire_names"] = [self.wire_names[q] for q in list(sorted(qubits))] circuit = self.__class__(**kwargs) circuit.add(gate.on_qubits(qubit_map) for gate in reversed(list_of_gates)) return circuit, qubit_map diff --git a/src/qibo/transpiler/optimizer.py b/src/qibo/transpiler/optimizer.py index 2ba05895e3..a30f117757 100644 --- a/src/qibo/transpiler/optimizer.py +++ b/src/qibo/transpiler/optimizer.py @@ -27,9 +27,9 @@ def __call__(self, circuit: Circuit) -> Circuit: ) if logical_qubits == physical_qubits: return circuit - new_wire_names = circuit.wire_names.copy() + [ - name for name in self.connectivity.nodes if name not in circuit.wire_names - ] + new_wire_names = circuit.wire_names + list( + self.connectivity.nodes - circuit.wire_names + ) new_circuit = Circuit(nqubits=physical_qubits, wire_names=new_wire_names) for gate in circuit.queue: new_circuit.add(gate) diff --git a/src/qibo/transpiler/placer.py b/src/qibo/transpiler/placer.py index f1ad7c6005..0e7d1ec136 100644 --- a/src/qibo/transpiler/placer.py +++ b/src/qibo/transpiler/placer.py @@ -147,8 +147,6 @@ def __call__(self, circuit: Circuit = None): Args: circuit (:class:`qibo.models.circuit.Circuit`): circuit to be transpiled. """ - if circuit is None: - raise_error(ValueError, "Circuit must be provided.") return diff --git a/tests/test_transpiler_placer.py b/tests/test_transpiler_placer.py index 86295022cb..90d4d301f7 100644 --- a/tests/test_transpiler_placer.py +++ b/tests/test_transpiler_placer.py @@ -102,13 +102,6 @@ def test_trivial(star_connectivity): assert_placement(circuit, connectivity) -def test_trivial_error(star_connectivity): - connectivity = star_connectivity() - placer = Trivial(connectivity=connectivity) - with pytest.raises(ValueError): - placer() - - def test_trivial_restricted(star_connectivity): names = ["q0", "q2"] circuit = Circuit(2, wire_names=names)