Skip to content

Commit

Permalink
add temporary if-else test
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMacCQ committed Dec 17, 2024
1 parent c424b24 commit 3b9189a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions if-else.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit import IfElseOp

qubits = QuantumRegister(2)
clbits = ClassicalRegister(2)
circuit = QuantumCircuit(qubits, clbits)
(q0, q1) = qubits
(c0, c1) = clbits

circuit.h(q0)
circuit.measure(q0, c0)

with circuit.if_test((c0, 1)) as else_:
circuit.h(q1)
with else_:
circuit.x(q1)
circuit.measure(q1, c1)

#print(circuit)


from pytket.extensions.qiskit import qiskit_to_tk
for datum in (circuit.data):
instr, qargs, cargs = datum.operation, datum.qubits, datum.clbits
if type(instr) is IfElseOp:
if_qc: QuantumCircuit = instr.params[0]
#print(if_qc.qregs)
#print(if_qc)
#tkc = qiskit_to_tk(if_qc)
#print(tkc.get_commands())

tkc = qiskit_to_tk(circuit)

0 comments on commit 3b9189a

Please sign in to comment.