-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text drawer support for controlled/conditional custom instruction #3199
Comments
Custom controlled instructions are not yet supported (waiting for #2862 ) On the conditional part, I think this is the code to test this situation (not fully sure, because I cannot visualize the result) from qiskit.circuit import Gate, Parameter
qinst = QuantumRegister(1, 'q')
cinst = ClassicalRegister(1, 'c')
inst = QuantumCircuit(qinst, cinst, name='instruction').to_instruction()
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qr, cr)
circuit.append(inst, [qr[0]], [cr[1]]).c_if(cr, 2)
circuit.draw(output='text') |
Also, it seems like text drawer also have problems with the following configuration: qr1 = QuantumRegister(1, 'qr')
cr1 = ClassicalRegister(1, 'cr')
qr2 = QuantumRegister(2, 'qr')
cr2 = ClassicalRegister(2, 'cr')
inst = QuantumCircuit(qr1, cr1, name='name').to_instruction()
circuit = QuantumCircuit(qr2, cr2)
circuit.append(inst, [qr2[0]], [cr2[1]])
print(circuit) |
Update for Santa:elf:- QGoGP✅ Issue still reproducible! Instruction object currently doesn't have an explicit custom control method and conditions with overlapping c_if and q_if drawings are not implemented yet as discussed and voted in Issue #3073. Second comment seems to be fixed but original drawer layout as mentioned by OP not yet implemented.
Current Output -
Expected -
Will update comment/add more comments if cause is found/fixed!
|
Based on the consensus in #3073, the text drawer should support controlled/conditional custom instructions
Considering the following custom instruction:
It would be possible to control on
q_1
and have a classical conditionc == 2
and the result should look like this:The text was updated successfully, but these errors were encountered: