-
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
Fix measure with condition display in mpl and latex drawers #6822
Conversation
Hi @enavarro51 . Nice one! I think supporting measure with condition in latex drawer has some issues. For instance, when You can notice here that it is hard to distinguish between the conditional bits and the bit on which the measurement is stored. I guess we would be able to overcome this issue if we had different notations for the conditional bits and the storage bit. I understand that it is a completely different issue that what this PR is for. But any opinions on that? |
@TharrmashasthaPV How does this look? Not perfect, but I think it solves your issue. |
@enavarro51 This certainly is better than having just dots. But I was thinking we could do something like I guess replacing |
@TharrmashasthaPV Very nice! Thought you might have a trick to use. I'll drop it in. Seems to work in all the cases I've tried. I added it to the cregbundle True as well. Is there a way to add a bullet in addition to the '= 1' at the condition creg? |
Awesome. For having both the bullet and |
Thanks a lot, @TharrmashasthaPV. Sometimes it's great to have someone else write your code for you. 😊 Anyway, I've extended this so the mpl and latex drawers should now show the same information for measures and conditionals. I'm not sure why mpl uses hex for the condition and the other 2 drawers don't. Maybe a discussion for another time. You may need to incorporate these changes in #6248 and #6259 at some point. |
Ok, but how is it relevant to the work in this PR? |
Uh, not really. Would you like it removed? |
Also, could you add a release note please 😄 |
Ah ok. Generally it's preferable to keep the content of PRs as relevant as possible to the original issue, and open new issues to cover extra things, but in this case it's quite small and not worth opening a whole new PR for it (and there is already scope creep with the switching to hex conditionals as well anyway) so I think just leave it |
Oh, 'scope creep'. I like that. 😊 Will do the release note. |
…-terra into measure_condition_6804
Release note added in 056eb8b. |
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 lgtm! Thanks for working on this, just a few merge conflicts left and I think it'll be good to go
@javabster Merge conflicts fixed in 3bd0c3e. |
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.
LGTM 🚀
qiskit/visualization/latex.py
Outdated
# Add (hex condition value) below the last cwire | ||
control = "\\control" if if_value[creg_size - 1] == "1" else "\\controlo" | ||
self._latex[creg_size + cwire - 1][col] = ( | ||
f"{control}" + " \\cw^(%s){^{%s}} \\cwx[-%s]" |
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.
The fix looks great! I was just curious to know if we could make a small aesthetic fix. In line 627, when we print the hex, it actually gets printed as a string inside a math environment. So it looks like
If we could just change this line to
f"{control}" + " \\cw^(%s){^{\\mathtt{%s}}} \\cwx[-%s]"
then we can get something like
which I personally think looks more like a hexadecimal. Any thoughts on this?
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.
Agreed. That x was a bit too fancy, and the new form is more compact as well. Will make the change.
…-terra into measure_condition_6804
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.
Perfect. LGTM.
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.
Thanks!
Fix measure with condition display in mpl and latex drawers (Qiskit#6822)
Summary
Fixes #6804
Details and comments
This PR fixes a problem where a measure with condition will sometimes display incorrectly in the 'mpl' and 'latex' drawers. The corrected displays are below.