question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MPL drawer support for complex custom instructions

See original GitHub issue

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')

image

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).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
yesodharan1892commented, Jan 9, 2020

hi, i think i have the solution for that , can you assign it to me so that i can look into it.

0reactions
yesodharan1892commented, May 17, 2021

Hi apologies as I’ve been offline due to some personal reasons. Seems the issue is addressed as per #6339

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learn How to Customize The Appearance of Your Qiskit ...
Learn How to Customize The Appearance of Your Qiskit Circuits (with Accessibility in Mind). Qiskit circuit drawer mosaic pattern. By Abby ...
Read more >
qiskit - understanding QuantumCircuit.x() function
MPL drawer should prioritize instruction label over name #3766 When an instruction has a label, the label should be used.
Read more >
qiskit.visualization.circuit_drawer
qiskit.visualization.circuit_drawer¶ ... Draw the quantum circuit. Use the output parameter to choose the drawing format: text: ASCII art TextDrawing that can be ...
Read more >
Resources - Marshall Furniture
For simple assembly items, Marshall Furniture will provide your team with installation instructions. For a complex, custom assembly, a third-party installer may ...
Read more >
Marker reference — Matplotlib 3.6.2 documentation
Matplotlib supports multiple categories of markers which are selected using the ... Use MathText, to use custom marker symbols, like e.g. "$\u266B$" ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found