-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add barrier labels and display in 3 circuit drawers #8440
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b7a3b79
Add barrier labels to mpl and text drawers
enavarro51 096c01a
Release note
enavarro51 a47b989
Merge branch 'main' into show_barrier_label
enavarro51 2ae33d9
Add import
enavarro51 389ce5b
Merge branch 'show_barrier_label' of github.com:enavarro51/qiskit-ter…
enavarro51 c84a44d
Lint
enavarro51 789f21b
Add barrier labels to latex drawer
enavarro51 ae09894
Merge branch 'main' into show_barrier_label
enavarro51 b26a3ed
Remove utils changes
enavarro51 cec670e
Merge branch 'main' into show_barrier_label
enavarro51 f79d27a
Cleanup
enavarro51 0e9b49e
Merge branch 'main' into show_barrier_label
enavarro51 e23aaaa
Fix merge conflict
enavarro51 959b9a6
Merge branch 'show_barrier_label' of github.com:enavarro51/qiskit-ter…
enavarro51 af5377d
Merge branch 'main' into show_barrier_label
enavarro51 7b3b92b
Lint
enavarro51 b8349db
Merge branch 'show_barrier_label' of github.com:enavarro51/qiskit-ter…
enavarro51 1a17e25
Remove label property for barriers and snapshots and increase mpl lab…
enavarro51 aa8241c
Merge branch 'main' into show_barrier_label
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
releasenotes/notes/add-barrier-label-8e677979cb37461e.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
features: | ||
- | | ||
Added a ``label`` parameter to the :class:`.Barrier` which now allows | ||
a user to enter a label for the ``barrier`` directive and the label | ||
will be printed at the top of the ``barrier`` in the `mpl`, `latex`, | ||
and `text` circuit drawers. Printing of existing ``snapshot`` labels | ||
to the 3 circuit drawers was also added. | ||
|
||
.. code-block:: python | ||
|
||
from qiskit import QuantumCircuit | ||
|
||
circuit = QuantumCircuit(2) | ||
circuit.h(0) | ||
circuit.h(1) | ||
circuit.barrier(label="After H") | ||
circuit.draw('mpl') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/python/visualization/references/test_latex_barrier_label.tex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
\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}_{0} : } & \lstick{{q}_{0} : } & \gate{\mathrm{X}} \barrier[0em]{1} & \qw & \gate{\mathrm{Y}} \barrier[0em]{1} & \cds{0}{^{\mathrm{End\,Y/X}}} & \qw & \qw\\ | ||
\nghost{{q}_{1} : } & \lstick{{q}_{1} : } & \gate{\mathrm{Y}} & \qw & \gate{\mathrm{X}} & \qw & \qw & \qw\\ | ||
\\ }} | ||
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Perhaps it would make more sense to wrap the label in
\text
instead of\mathrm
- the latter still uses math-mode spacing/kerning rules (hence the\,
), whereas\text
swaps back to the full text font. It depends onamsmath
being available (I think), but that's part of the de facto LaTeX standard library. Users would be able to have parts of the label rendered in math-mode by including the$ ... $
manually.That's just on the basis that I would expect "label" to be a text field, not an equation one. If we feel like it's more of an "equation" field, then the current math-mode way makes sense.
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.
\text
doesn't work on my TeX Live version of LaTex. I don't think we'd want to do anotherusepackage
foramsmath
just for this, so I'd suggest we leave the\mathrm
as is.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.
Yeah, that's fair enough. I'm surprised that nothing is already loading
amsmath
, since it's about as common asimport numpy
in mathematical Python code, but fair enough. If it's not already loaded, yeah, let's not add the extra dependency.