microsoft / qsharp

Azure Quantum Development Kit, including the Q# programming language, resource estimator, and Quantum Katas
https://microsoft.github.io/qsharp/
MIT License
446 stars 90 forks source link

Make DumpMachine/DumpRegister output more compact and reduce use of Unicode symbols #1699

Open tcNickolas opened 3 months ago

tcNickolas commented 3 months ago

Is your feature request related to a problem? Please describe.

  1. DumpMachine output is very verbose. In my default screen layout, I can see one complete DumpMachine output with 4 basis states, anything extra requires scrolling. Our teleportation sample, for example, has 8 DumpMachine outputs, requiring a lot of scrolling, and the "DumpMachine:" headers and empty lines dominate the output.
  2. Symbols ⟩ and 𝑖 are not recognized by a lot of editing environments (such as LaTeX), so copy-pasting DumpMachine output requires post-production.

Describe the solution you'd like

  1. Remove "DumpMachine:" header from before the table of basis states, and some of the empty lines around it.
  2. Replace 𝑖 with i in the complex number output. I don't think we can replace ⟩ as easily, using > is very ugly, but having i in italic doesn't add a lot of visual value.
sezna commented 2 months ago

Point number 1 around removing DumpMachine is certainly doable and a likely improvement, but number 2 introduces an inconsistency that we are undecided on. We think it makes more sense to either leave unicode in or remove all unicode.

tcNickolas commented 2 months ago

Not all Unicode is equal :-) There is a lot of value in using ⟩ instead of > for ket, but having i in italic is not important, so I'm willing to trade off some non-uniformity for better usability

sezna commented 2 months ago

I think the concern is more about what precisely the usability improvement is. As far as I understand, having a unicode string is of usability level X, and having a non-unicode string is of usability level Y. Removing some but not all unicode does not change the usability level from X to Y, as any external tools you're using still have to deal with a unicode string. I understand the sentiment that the italic 𝒊 is less important, but I mean...if we are already outputting strings of usability level X, we might as well take full advantage of this and provide the most prettified output possible, right?

tcNickolas commented 2 months ago

It does actually change usability, since I need to make a decision about what to do with each type of character individually. Reducing the number of characters to think about improves usability

tcNickolas commented 2 months ago

One more odd thing I noticed was that the minus signs in the second and the last columns were different, one was highlighted as special by VS Code. That didn't cause any rendering issues with my particular platform, but looked odd

swernli commented 2 months ago

Looks like #1885 addresses at least the first point, removing the titles from the output.