Skip to content
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

[BUG] ASCII plots do not format correctly #557

Open
jon-wurtz opened this issue May 10, 2023 · 3 comments
Open

[BUG] ASCII plots do not format correctly #557

jon-wurtz opened this issue May 10, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jon-wurtz
Copy link
Collaborator

Describe the bug
The ASCII-style default plots of waveforms do not render correctly

To Reproduce
Copied from https://queracomputing.github.io/Bloqade.jl/dev/tutorials/5.MIS/main/

T_max = 0.6
Ω_max = 2π * 4
Ω = piecewise_linear(clocks = [0.0, 0.1, 0.5, T_max], values = [0.0, Ω_max, Ω_max, 0])
Δ_start = -2π * 13
Δ_end = 2π * 11
Δ = piecewise_linear(clocks = [0.0, 0.1, 0.5, T_max], values = [Δ_start, Δ_start, Δ_end, Δ_end])

Expected behavior
A correctly formatted graph with no misalignments

Screenshots
image

Version Info

  • 1.8.2
  • jupyter notebook in VSCode

Additional context
Add any other context about the problem here.

@jon-wurtz jon-wurtz added the bug Something isn't working label May 10, 2023
@johnzl-777 johnzl-777 self-assigned this May 11, 2023
@johnzl-777
Copy link
Collaborator

I suspect this has to do with this known UnicodePlots issue: https://github.com/JuliaPlots/UnicodePlots.jl#known-issues

Let me try to replicate the problem on my end but in the mean time but I think it would be worth allowing Bloqade to either auto-detect character set support (this would be great for avoiding some issues with plots that have a unicode character) OR letting users explicitly toggle if they want unicode/standard ASCII.

@Roger-luo do you know if auto-detection is possible? If not I can probably just allow the user to set some package-level variable like UNICODE_PLOTS=false

@Roger-luo
Copy link
Member

I think this might due to your terminal is not using mono fonts - which will not just cause problem in Unicode plots, but will also making your code not align correctly (at least inside terminal)

do you know if auto-detection is possible? If not I can probably just allow the user to set some package-level variable like UNICODE_PLOTS=false

It's possible but not worth it, and what if there are no mono fonts available? a global option to turn it off could be fine, but this provides much more information even if it's not rendered correctly compared to a naive print of the waveform type. We should advise users to change their font and provide this option as a fallback if they have problem changing fonts.

@johnzl-777
Copy link
Collaborator

@Roger-luo apologies on my end, I spoke too hastily. I think my original idea with "Disable Unicode" would probably just:

  1. ensure standard plots from Bloqade outside the terminal don't use any unicode characters
  2. Pass the border=:dotted argument to UnicodePlots although I'm skeptical if this would ameliorate @jon-wurtz 's issue or anyone with a non-monospace font.

In the spirit of actually preserving most of what we can do with Unicode but with ASCII:

I see at one point there was an ASCIIPlots package for Julia but it seems to be officially dead (and from personal experimentation shows far less useful detail than a semi-broken Unicode plot).

I think another solution might be to take advantage of tree printing and show at each t what the value is. This would work nicely for linear and piecewise constant waveforms (just show the values at the endpoints or the main time points) but for arbitrary waveforms something else would have to be done.

In any case, I agree it's worth putting a notice somewhere in the documentation for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants