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 support for barriers to latex_drawer() #764
Conversation
This is still WIP because the fixed offset for drawing barriers will overlap with the box for measurement if it's immediately after a gate. (because the measurement image is wider than a gate) |
@mtreinish It seems like your change has been released as part of Qcircuit, based on the conversation here: CQuIC/qcircuit#34. So is this PR ready to be taken out of WIP and merged? |
@ajavadia it's still not quite ready yet. There is still an issue with the horizontal spacing between elements on the circuit. Like if you put it between a gate and a meter the barrier will overlap with the meter box. Unfortunately the fix for that will be kind of tricky to implement as the latex is generated today, because we won't be able to tell if there is anything on a qubit (and then know how much to space the barrier to center it) when we generate the \barrier string. I'll see if I can come up with a way to get it working tomorrow. This will also need to be updated to remove the redefinition of \barrier since it's in a CTAN release now. |
This commit adds support for drawing barriers to the latex_drawer(). The Qcircuit LaTeX package was recently updated with the \barrier command, which must be installed in your latex distribution for barriers to work. Fixes Qiskit#731
59ef60c
to
e0b8990
Compare
@ajavadia I've updated the patch to try and address those issues. The spacing for the barriers is still a bit weird because it's still not truly dynamic. So there are likely cases where the barrier won't be properly drawn in the middle of elements because it's naively assuming fixed spacing. That being said it seems to work for my simple test:
|
@mtreinish can you please add the following commands to be drawn like barriers also? These are simulator-specific instructions, and behave like barriers. So the circuit drawer should draw them like barriers. They are available when you do |
@ajavadia sure I can look into that. But I think it'll be better to do add support for the other commands in a follow up PR. Since it'll take me a bit of time to figure out how to best draw the annotation next to the barrier line. |
@mtreinish Sure, that can be done later. The current barrier plotting looks great. Merging. |
This commit adds support for drawing barriers to the latex_drawer(). The Qcircuit LaTeX package was recently updated with the \barrier command, which must be installed in your latex distribution for barriers to work. Fixes Qiskit#731
Summary
This commit adds support for drawing barriers to the latex_drawer(). The
Qcircuit LaTeX package doesn't have support for drawing barriers yet
(it's pending with CQuIC/qcircuit#33 ) so for now this commit inlines
the command definition. In the future when the Qcircuit package is
released to include the command we can remove that.
Details and comments
Fixes #731