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

plot error? #439

Open
Wangwei-Lan opened this issue Nov 1, 2022 · 11 comments
Open

plot error? #439

Wangwei-Lan opened this issue Nov 1, 2022 · 11 comments
Labels
bug Something isn't working

Comments

@Wangwei-Lan
Copy link

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 as circuit1, 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?

@GiggleLiu
Copy link
Member

GiggleLiu commented Nov 1, 2022

Maybe I know which editor are you using? I tried VSCode, it plots correctly.

@Wangwei-Lan
Copy link
Author

I am not using an editor, I used Jupiter notebook. For Vscode, it works fine.

@Roger-luo Roger-luo added the bug Something isn't working label Dec 6, 2022
@Egg12138
Copy link

Egg12138 commented Dec 8, 2022

I met a problem alike yesterday.

(Both in Jupyter notebook & VSCode builtin
jupyter notebook)
platform: WSL Ubuntu20.04LTS.
using Yao, YaoPlots

step1

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

step2

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

step3

I clean the output of the step1 block
the output of step2 immediately changed into the correct chain:
Y
H
H

step4

I re-executed the step1 block,
step2 block changed again:
Y
Z
Z

step5

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

step6

repeat: I clear the step2 output,
the step5 block plot correctly:
X
H
X

step7

I insert a new block after step1 block, wrong plots happened again.

step8

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...)

step9

even if I using Plots, same things happened.

@GiggleLiu
Copy link
Member

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: JuliaGraphics/Luxor.jl#226

@GiggleLiu
Copy link
Member

FYI: the reltated code block is https://github.com/QuantumBFS/YaoPlots.jl/blob/0157a3e8d57113d6219a8dba9d2f320f99fc1395/src/vizcircuit.jl#L463

@Egg12138
Copy link

Egg12138 commented Dec 8, 2022

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: JuliaGraphics/Luxor.jl#226

thanks. I'll try the solution in the quoted issues.

@cormullion
Copy link

I think this is the infamous "SVG/Jupyter cell interaction" problem, summarised by knuesel here: MakieOrg/Makie.jl#952 (comment)

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 (JuliaGraphics/Luxor.jl#228) - but Pluto handles SVGs more carefully than Jupyter and doesn't have this problem.

@cormullion
Copy link

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...)

Screenshot 2022-12-08 at 11 10 07

@GiggleLiu
Copy link
Member

Thanks, that would be great!

@Egg12138
Copy link

Egg12138 commented Dec 8, 2022

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...)

Screenshot 2022-12-08 at 11 10 07

That's awesome.Thanks!

@cormullion
Copy link

hopefully fixed in Luxor 3.6.0.

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

5 participants