The following circuit is being draw like wrongly:
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]])
circuit.draw(output='mpl')

It should be similar to this:
Considering the following custom instruction:
โโโโโโโโโโโโโโโ
q_0: |0>โค1 โ
โ โ
q_1: |0>โค โ
โ instruction โ
c_0: 0 โก โ
โ โ
c_1: 0 โก0 โ
โโโโโโโโโโโโโโโ
Additionally, based on the consensus in #3073, the mpl drawer should support controlled/conditional custom instructions. The following is an example for conditional:
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='mpl')
Controlled is not yet supported (see #2862).
hi,
i think i have the solution for that , can you assign it to me so that i can look into it.
@yesodharan1892 can you draw instances of ControlledGate in matplotlib's circuit visualizer? This is kind of high priority. Currently this is only doable in the text drawer (https://github.com/Qiskit/qiskit-terra/pull/3442)
hi @ajavadia i have made some changes in the code given above and the mpl visualization is what as is expected, but when i look at the text visualization it seems to be wrong.
from qiskit import *
from qiskit.circuit import Gate, Parameter
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
inst = QuantumCircuit(qr, cr, name='instruction').to_instruction()
%matplotlib inline
circuit = QuantumCircuit(qr, cr)
circuit.append(inst, [qr[1], qr[0]],[cr[0],cr[1]])
circuit.draw(output='mpl')


this is the expectated visualization for q0 acting on c0 as it is shown below.

i look at the latex visualization it seems to be wrong.
you mean "text visualizer"?
yes i m sorry , i meant text visualizer...
Most helpful comment
hi,
i think i have the solution for that , can you assign it to me so that i can look into it.