-
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
Relax wire_order restrictions in circuit visualization #9893
Changes from 7 commits
c172441
8d3e170
487d2d7
b0994c7
6adb48b
d1aeffb
95095d9
1bbf5b7
ac2ee27
8aa8904
2fb598f
5416f70
6a1f792
f229974
08f109a
202353e
acc1b0d
c541c6b
312273f
b94ac8d
445489c
d2224cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
features: | ||
- | | ||
Some restrictions when using ``wire_order`` in the circuit drawers had been relaxed. | ||
Now, ``wire_order`` does not need to be a complete list and it can be used | ||
with ``cregbundle=True`` when the order is not affecting the classical bits. | ||
|
||
.. code-block:: | ||
|
||
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister | ||
|
||
qr = QuantumRegister(4, "q") | ||
cr = ClassicalRegister(4, "c") | ||
cr2 = ClassicalRegister(2, "ca") | ||
circuit = QuantumCircuit(qr, cr, cr2) | ||
circuit.h(0) | ||
circuit.h(3) | ||
circuit.x(1) | ||
circuit.x(3).c_if(cr, 10) | ||
circuit.draw('text', wire_order=[2, 3], cregbundle=True) | ||
|
||
.. parsed-literal:: | ||
|
||
q_2: ──────────── | ||
┌───┐ ┌───┐ | ||
q_3: ┤ H ├─┤ X ├─ | ||
├───┤ └─╥─┘ | ||
q_0: ┤ H ├───╫─── | ||
├───┤ ║ | ||
q_1: ┤ X ├───╫─── | ||
└───┘┌──╨──┐ | ||
c: 4/═════╡ 0xa ╞ | ||
└─────┘ | ||
ca: 2/════════════ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this example will work after the new changes any more because of the partial wire order. We should replace it with one that assigns all qubits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops... fixed in d2224cd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
\documentclass[border=2px]{standalone} | ||
|
||
\usepackage[braket, qm]{qcircuit} | ||
\usepackage{graphicx} | ||
|
||
\begin{document} | ||
\scalebox{1.0}{ | ||
\Qcircuit @C=1.0em @R=0.2em @!R { \\ | ||
\nghost{{q}_{2} : } & \lstick{{q}_{2} : } & \qw & \qw & \qw & \qw\\ | ||
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \gate{\mathrm{X}} & \qw & \qw & \qw\\ | ||
\nghost{{q}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{H}} & \qw & \qw & \qw\\ | ||
\nghost{{q}_{3} : } & \lstick{{q}_{3} : } & \gate{\mathrm{H}} & \gate{\mathrm{X}} & \qw & \qw\\ | ||
\nghost{{c}_{0} : } & \lstick{{c}_{0} : } & \cw & \controlo \cw \cwx[-1] & \cw & \cw\\ | ||
\nghost{{c}_{1} : } & \lstick{{c}_{1} : } & \cw & \controlo \cw \cwx[-1] & \cw & \cw\\ | ||
\nghost{{c}_{2} : } & \lstick{{c}_{2} : } & \cw & \control \cw \cwx[-1] & \cw & \cw\\ | ||
\nghost{{c}_{3} : } & \lstick{{c}_{3} : } & \cw & \control \cw^(0.0){^{\mathtt{0xc}}} \cwx[-1] & \cw & \cw\\ | ||
\nghost{{ca}_{0} : } & \lstick{{ca}_{0} : } & \cw & \cw & \cw & \cw\\ | ||
\nghost{{ca}_{1} : } & \lstick{{ca}_{1} : } & \cw & \cw & \cw & \cw\\ | ||
\\ }} | ||
\end{document} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated. I just saw it around and noticed that QA&A is not a very common acronym.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be better to revert this, especially with opflow deprecated. It's a problem that's existed forever (and capitalising unexpected words in a sentence like this is a not-altogether-unheard-of way of implicitly defining an acronym anyway).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in b94ac8d