Open Wangwei-Lan opened 1 year ago
Maybe I know which editor are you using? I tried VSCode, it plots correctly.
I am not using an editor, I used Jupiter notebook. For Vscode, it works fine.
I met a problem alike yesterday.
(Both in Jupyter notebook & VSCode builtin
jupyter notebook)
platform: WSL Ubuntu20.04LTS.
using Yao, YaoPlots
In one block, I wrote:
chainYHZ = chain(3, put(1=>Y), put(2=>Z), put(3=>Z), repeat(Z, 1:3))
plot(chainYHZ)
output is as expected: Y-Z Z-Z Z-Z
then I ran another block of codes: chainYHH = chain(3, put(1=>Y), put(2=>H), put(3=>H)) plot(chainYHH)
output is wrong: Y Z Z
I clean the output of the step1 block the output of step2 immediately changed into the correct chain: Y H H
I re-executed the step1 block, step2 block changed again: Y Z Z
I cleared output of step1 block again, (yeah, the step2 output remain correct: Y H H )
then
I added a new block after step2 block, denoted by step5 block.
chain5 = chain(3, put(1=>X), put(2=>H), put(3=>X))
plot(chain5)
the output is: Y H Y
repeat: I clear the step2 output, the step5 block plot correctly: X H X
I insert a new block after step1 block, wrong plots happened again.
I use println(chainXXX)
, the output is always correct but julia plots incorrectly when plot outputs of other code blocks exist.
I don't know why.
(I'm new for Yao.jl
so I'm not sure whether it's a feature...)
even if I using Plots
, same things happened.
The plotting backend we are using is Luxor. IIUC, it is a wield interaction between Luxor and Jupyter. @cormullion do you have any idea? Maybe this issue is related: https://github.com/JuliaGraphics/Luxor.jl/issues/226
FYI: the reltated code block is https://github.com/QuantumBFS/YaoPlots.jl/blob/0157a3e8d57113d6219a8dba9d2f320f99fc1395/src/vizcircuit.jl#L463
The plotting backend we are using is Luxor. IIUC, it is a wield interaction between Luxor and Jupyter. @cormullion do you have any idea? Maybe this issue is related: https://github.com/JuliaGraphics/Luxor.jl/issues/226
thanks. I'll try the solution in the quoted issues.
I think this is the infamous "SVG/Jupyter cell interaction" problem, summarised by knuesel here: https://github.com/MakieOrg/Makie.jl/issues/952#issuecomment-842413678
ie
SVGs in different cells in a Jupyter notebook share definitions, which is usually not what you want.
A related issue was found in Pluto (https://github.com/JuliaGraphics/Luxor.jl/issues/228) - but Pluto handles SVGs more carefully than Jupyter and doesn't have this problem.
Since this is a common problem people encounter when using Jupyter, I'll add a workaround to the next Luxor release. (Very large SVGs might take a bit longer to display, perhaps...)
Thanks, that would be great!
Since this is a common problem people encounter when using Jupyter, I'll add a workaround to the next Luxor release. (Very large SVGs might take a bit longer to display, perhaps...)
![]()
That's awesome.Thanks!
hopefully fixed in Luxor 3.6.0.
Hello,
I plotted a circuit in jupyter notebook in one cell, it worked fine. However, I continue to plot another circuit in the next cell, it always give me error. See below
circuit1 = chain(1, put(1=>H)); plot(circuit1)
circuit2 = chain(1, put(1=>X)); plot(circuit2)
The first one gives me the correct H gate, but I run the second code,circuit2
always gives me the same plot ascircuit1
, which is incorrect since it is an X gate. I am not quite sure whether it is a bug or it is because the setup on my computer is wrong. Could you help me verify that?