Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMacCQ committed Dec 17, 2024
1 parent e38ca3e commit 3843234
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions pytket/extensions/qiskit/qiskit_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/qiskit_convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3843234

Please sign in to comment.