From 3843234e87e0c890e9bc3ee8f3b716f120248583 Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:58:57 +0000 Subject: [PATCH] formatting --- pytket/extensions/qiskit/qiskit_convert.py | 12 +++++------- tests/qiskit_convert_test.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pytket/extensions/qiskit/qiskit_convert.py b/pytket/extensions/qiskit/qiskit_convert.py index 17e74dca..a910d5b5 100644 --- a/pytket/extensions/qiskit/qiskit_convert.py +++ b/pytket/extensions/qiskit/qiskit_convert.py @@ -479,16 +479,17 @@ def _build_circbox(instr: Instruction, circuit: QuantumCircuit) -> CircBox: subc.name = instr.name return CircBox(subc) + # TODO refactor to reduce duplication def _pytket_boxes_from_IfElseOp(instr: Instruction) -> tuple[CircBox, CircBox]: if_qc: QuantumCircuit = instr.params[0] else_qc: QuantumCircuit = instr.params[1] # TODO handle non-simple register case? - default_qreg_if = QuantumRegister(if_qc.num_qubits, "q") - default_creg_if = ClassicalRegister(if_qc.num_clbits, "c") - default_qreg_else = QuantumRegister(else_qc.num_qubits, "q") - default_creg_else = ClassicalRegister(else_qc.num_clbits, "c") + default_qreg_if = QuantumRegister(if_qc.num_qubits, "q") + default_creg_if = ClassicalRegister(if_qc.num_clbits, "c") + default_qreg_else = QuantumRegister(else_qc.num_qubits, "q") + default_creg_else = ClassicalRegister(else_qc.num_clbits, "c") new_if_qc = QuantumCircuit(default_qreg_if, default_creg_if) new_else_qc = QuantumCircuit(default_qreg_else, default_creg_else) @@ -498,7 +499,6 @@ def _pytket_boxes_from_IfElseOp(instr: Instruction) -> tuple[CircBox, CircBox]: if_circuit = if_builder.circuit() if_circuit.name = "If" - else_builder = CircuitBuilder(new_else_qc.qregs, new_else_qc.cregs) else_builder.add_qiskit_data(else_qc) else_circuit = else_builder.circuit() @@ -507,8 +507,6 @@ def _pytket_boxes_from_IfElseOp(instr: Instruction) -> tuple[CircBox, CircBox]: return CircBox(if_circuit), CircBox(else_circuit) - - class CircuitBuilder: def __init__( self, diff --git a/tests/qiskit_convert_test.py b/tests/qiskit_convert_test.py index 6e7c1e11..9155042a 100644 --- a/tests/qiskit_convert_test.py +++ b/tests/qiskit_convert_test.py @@ -1197,7 +1197,7 @@ def test_ifelseop_handling() -> None: circuit = QuantumCircuit(qubits, clbits) (q0, q1) = qubits (c0, c1) = clbits - + circuit.h(q0) circuit.measure(q0, c0)