Skip to content

Commit

Permalink
Do not delete the quantum wire behind a gate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov committed May 8, 2021
1 parent 6a8ce7e commit 7532de6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Quantikz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function draw_rectangle!(table,step,targets,str)
table[i,step] = "\\linethrough"
end
else
table[i,step] = ""
table[i,step] = "\\qw"
end
end
offset = iseven(M-m) && ((m+M)/2 vcat(targets,deleted)) && !occursin("\\\\",str) ? ",label style={yshift=0.2cm}" : ""
Expand Down
36 changes: 21 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ circuit = [
MultiControlU("U_b",[7,8],[],[1,2,3]),
MultiControlU("U_c",[],[],[4,6])
]
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\ctrl{0} & \\gate[3,disable auto height]{U_b} & \\qw & \\qw\\\\\n\\qw & \\ctrl{-1} & \\ctrl{-1} & & \\qw & \\qw\\\\\n\\qw & \\octrl{-1} & \\qw & & \\qw & \\qw\\\\\n\\qw & \\qw & \\gate[2,disable auto height]{U_a}\\vqw{-2} & \\qw & \\gate[3,label style={yshift=0.2cm},disable auto height]{U_c} & \\qw\\\\\n\\qw & \\gate[3,label style={yshift=0.2cm},disable auto height]{U}\\vqw{-2} & & \\qw & \\linethrough & \\qw\\\\\n\\qw & \\linethrough & \\qw & \\qw & & \\qw\\\\\n\\qw & & \\qw & \\ctrl{-4} & \\qw & \\qw\\\\\n\\qw & \\octrl{-1} & \\qw & \\ctrl{-1} & \\qw & \\qw\n\\end{quantikz}"
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\ctrl{0} & \\gate[3,disable auto height]{U_b} & \\qw & \\qw\\\\\n\\qw & \\ctrl{-1} & \\ctrl{-1} & \\qw & \\qw & \\qw\\\\\n\\qw & \\octrl{-1} & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\gate[2,disable auto height]{U_a}\\vqw{-2} & \\qw & \\gate[3,label style={yshift=0.2cm},disable auto height]{U_c} & \\qw\\\\\n\\qw & \\gate[3,label style={yshift=0.2cm},disable auto height]{U}\\vqw{-2} & \\qw & \\qw & \\linethrough & \\qw\\\\\n\\qw & \\linethrough & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\ctrl{-4} & \\qw & \\qw\\\\\n\\qw & \\octrl{-1} & \\qw & \\ctrl{-1} & \\qw & \\qw\n\\end{quantikz}"

circuit = [
CNOT(1,2),
Expand All @@ -32,7 +32,7 @@ circuit = [
Measurement("XY",[3,4],1),
Measurement(1)
]
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\meterD{} & & & \\\\\n\\qw & \\targ{}\\vqw{-1} & \\qw & & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\meterD{} & & & & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & & \\qw & \\qw\\\\\n & & \\lstick{} & \\ctrl{-3} & \\meterD{} & \\lstick{} & \\ctrl{-1} & \\meterD{} & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw\\\\\n\\cw & \\cw & \\cw & \\cw & \\cwbend{-2} & \\cw & \\cw & \\cw & \\cw\n\\end{quantikz}"
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\meterD{} & & & \\\\\n\\qw & \\targ{}\\vqw{-1} & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\meterD{} & & & & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n & & \\lstick{} & \\ctrl{-3} & \\meterD{} & \\lstick{} & \\ctrl{-1} & \\meterD{} & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw\\\\\n\\cw & \\cw & \\cw & \\cw & \\cwbend{-2} & \\cw & \\cw & \\cw & \\cw\n\\end{quantikz}"

circuit = [
Noise([1,5]),
Expand All @@ -41,7 +41,7 @@ circuit = [
MultiControlU("U",[2],[],[3,4]),
Noise([2,4]),
]
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\gate{P} & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\ctrl{0} & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw\\\\\n\\qw & \\qw & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\gate[2,disable auto height]{U}\\vqw{-1} & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw\\\\\n\\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\qw & \\qw\n\\end{quantikz}"
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\gate{P} & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\ctrl{0} & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw\\\\\n\\qw & \\qw & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\gate[2,disable auto height]{U}\\vqw{-1} & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw\\\\\n\\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\qw & \\qw & \\qw\n\\end{quantikz}"

circuit = [
CNOT(1,2),
Expand All @@ -53,25 +53,30 @@ circuit = [
Measurement(1),
Measurement(4)
]
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\meterD{} & \\meterD{} & & & & \\\\\n\\qw & \\targ{}\\vqw{-1} & \\qw & & \\qw & \\qw & \\qw & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw\\\\\n\\qw & \\meterD{} & & & & \\qw & \\gate[2,disable auto height]{XY} & \\qw & & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & & \\qw & \\qw & \\meterD{} & \\\\\n & & \\lstick{} & \\ctrl{-3} & \\meterD{} & \\lstick{} & \\ctrl{-1} & \\meterD{} & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cwbend{-3} & \\cw & \\cw\\\\\n\\cw & \\cw & \\cw & \\cw & \\cwbend{-2} & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw & \\cw\n\\end{quantikz}"
@test circuit2string(circuit, mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw & \\qw & \\qw & \\meterD{} & & \\meterD{} & & \\\\\n\\qw & \\targ{}\\vqw{-1} & \\qw & \\qw & & \\qw & \\qw & \\qw & \\qw & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\meterD{} & & & & & \\gate[2,disable auto height]{XY} & \\qw & \\qw & & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & & \\qw & \\qw & \\qw & \\qw & \\meterD{} & \\\\\n & & & \\lstick{} & \\ctrl{-3} & \\meterD{} & \\lstick{} & \\ctrl{-1} & \\meterD{} & & & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw & \\cwbend{-3} & \\cw & \\cw & \\cw\\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-2} & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw & \\cw & \\cw\n\\end{quantikz}"
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\meterD{} & \\meterD{} & & & & \\\\\n\\qw & \\targ{}\\vqw{-1} & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw\\\\\n\\qw & \\meterD{} & & & & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\meterD{} & \\\\\n & & \\lstick{} & \\ctrl{-3} & \\meterD{} & \\lstick{} & \\ctrl{-1} & \\meterD{} & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cwbend{-3} & \\cw & \\cw\\\\\n\\cw & \\cw & \\cw & \\cw & \\cwbend{-2} & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw & \\cw\n\\end{quantikz}"
@test circuit2string(circuit, mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw & \\qw & \\qw & \\meterD{} & & \\meterD{} & & \\\\\n\\qw & \\targ{}\\vqw{-1} & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\gate[2,disable auto height]{XY} & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\meterD{} & & & & & \\gate[2,disable auto height]{XY} & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\meterD{} & \\\\\n & & & \\lstick{} & \\ctrl{-3} & \\meterD{} & \\lstick{} & \\ctrl{-1} & \\meterD{} & & & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw & \\cwbend{-3} & \\cw & \\cw & \\cw\\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-2} & \\cw & \\cw & \\cw & \\cw & \\cwbend{-1} & \\cw & \\cw & \\cw\n\\end{quantikz}"
end

@testset "No overlaps in compressed table" begin
@test circuit2string([CNOT(3,2),CNOT(1,4)]) == circuit2string([CNOT(3,2),CNOT(1,4)], mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\ctrl{0} & \\qw\\\\\n\\qw & \\targ{}\\vqw{0} & \\qw & \\qw\\\\\n\\qw & \\ctrl{-1} & \\qw & \\qw\\\\\n\\qw & \\qw & \\targ{}\\vqw{-3} & \\qw\n\\end{quantikz}"
@test circuit2string([CNOT(1,4),CNOT(3,2)]) == circuit2string([CNOT(1,4),CNOT(3,2)], mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\qw\\\\\n\\qw & \\qw & \\targ{}\\vqw{0} & \\qw\\\\\n\\qw & \\qw & \\ctrl{-1} & \\qw\\\\\n\\qw & \\targ{}\\vqw{-3} & \\qw & \\qw\n\\end{quantikz}"
circuit = [CNOT(3,2),CNOT(1,4)]
@test circuit2string(circuit) == circuit2string(circuit, mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\ctrl{0} & \\qw\\\\\n\\qw & \\targ{}\\vqw{0} & \\qw & \\qw\\\\\n\\qw & \\ctrl{-1} & \\qw & \\qw\\\\\n\\qw & \\qw & \\targ{}\\vqw{-3} & \\qw\n\\end{quantikz}"
circuit = [CNOT(1,4),CNOT(3,2)]
@test circuit2string(circuit) == circuit2string(circuit, mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\ctrl{0} & \\qw & \\qw\\\\\n\\qw & \\qw & \\targ{}\\vqw{0} & \\qw\\\\\n\\qw & \\qw & \\ctrl{-1} & \\qw\\\\\n\\qw & \\targ{}\\vqw{-3} & \\qw & \\qw\n\\end{quantikz}"
end

@testset "NoiseAll on just qubits" begin
@test circuit2string([NoiseAll(), Measurement(1,2)]) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\meterD{} & \\\\\n\\cw & \\cw & \\cw & \\cw\\\\\n\\cw & \\cw & \\cwbend{-2} & \\cw\n\\end{quantikz}"
circuit = [NoiseAll(), Measurement(1,2)]
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\gate[1,style={starburst,starburst points=7,inner xsep=-2pt,inner ysep=-2pt,scale=0.5}]{} & \\meterD{} & \\\\\n\\cw & \\cw & \\cw & \\cw\\\\\n\\cw & \\cw & \\cwbend{-2} & \\cw\n\\end{quantikz}"
end

@testset "Clearance for vertical classical wires" begin
@test circuit2string([Measurement(2),Measurement(1,1)]) == circuit2string([Measurement(2),Measurement(1,1)], mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\meterD{} & \\\\\n\\qw & \\meterD{} & & \\\\\n\\cw & \\cw & \\cwbend{-2} & \\cw\n\\end{quantikz}"
circuit = [Measurement(2),Measurement(1,1)]
@test circuit2string(circuit) == circuit2string(circuit, mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\meterD{} & \\\\\n\\qw & \\meterD{} & & \\\\\n\\cw & \\cw & \\cwbend{-2} & \\cw\n\\end{quantikz}"
end

@testset "Avoiding placement of already deleted wires on top of rectangles" begin
c =[Measurement(2),
circuit = [
Measurement(2),
U(3), U(3),
MultiControlU("A", [1, 3]),
U(3),
Expand All @@ -82,14 +87,15 @@ c =[Measurement(2),
Measurement([1,3]),
U(3),
ClassicalDecision([1,3],1)]
@test circuit2string(c) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{A} & \\qw & \\gate[4,nwires={2},disable auto height]{A} & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw\\\\\n\\qw & \\meterD{} & & & & & & & & & & & & & \\\\\n\\qw & \\gate{\\;\\;} & \\gate{\\;\\;} & & \\gate{\\;\\;} & \\linethrough & \\gate{\\;\\;} & & \\gate{\\;\\;} & \\qw & & \\qw & \\gate{\\;\\;} & & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n & & & & & & & & & \\lstick{} & \\ctrl{-2} & \\meterD{} & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-3} & \\cw\n\\end{quantikz}"
@test circuit2string(c,mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{A} & \\qw & \\gate[4,nwires={2},disable auto height]{A} & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw\\\\\n\\qw & \\meterD{} & & & & & & & & & & & & & & \\\\\n\\qw & \\qw & \\gate{\\;\\;} & \\gate{\\;\\;} & & \\gate{\\;\\;} & \\linethrough & \\gate{\\;\\;} & & \\gate{\\;\\;} & \\qw & & \\qw & \\gate{\\;\\;} & & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n & & & & & & & & & & \\lstick{} & \\ctrl{-2} & \\meterD{} & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-3} & \\cw\n\\end{quantikz}"
@test circuit2string(circuit) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{A} & \\qw & \\gate[4,nwires={2},disable auto height]{A} & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw\\\\\n\\qw & \\meterD{} & & & & & & & & & & & & & \\\\\n\\qw & \\gate{\\;\\;} & \\gate{\\;\\;} & \\qw & \\gate{\\;\\;} & \\linethrough & \\gate{\\;\\;} & \\qw & \\gate{\\;\\;} & \\qw & \\qw & \\qw & \\gate{\\;\\;} & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n & & & & & & & & & \\lstick{} & \\ctrl{-2} & \\meterD{} & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-3} & \\cw\n\\end{quantikz}"
@test circuit2string(circuit,mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{A} & \\qw & \\gate[4,nwires={2},disable auto height]{A} & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw & \\qw & \\gate[3,nwires={2},disable auto height]{\\;\\;} & \\qw\\\\\n\\qw & \\meterD{} & & & & & & & & & & & & & & \\\\\n\\qw & \\qw & \\gate{\\;\\;} & \\gate{\\;\\;} & \\qw & \\gate{\\;\\;} & \\linethrough & \\gate{\\;\\;} & \\qw & \\gate{\\;\\;} & \\qw & \\qw & \\qw & \\gate{\\;\\;} & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw & \\qw\\\\\n & & & & & & & & & & \\lstick{} & \\ctrl{-2} & \\meterD{} & & & \\\\\n\\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cw & \\cwbend{-3} & \\cw\n\\end{quantikz}"
end

@testset "EndpointRanges in ClassicalDecision" begin
c = [U(5),ClassicalDecision(ibegin:iend,2),ClassicalDecision(1,ibegin:iend)]
@test circuit2string(c) == circuit2string(c,mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\gate[5,disable auto height]{\\;\\;} & \\gate[1]{\\;\\;} & \\qw\\\\\n\\qw & \\qw & & \\qw & \\qw\\\\\n\\qw & \\qw & & \\qw & \\qw\\\\\n\\qw & \\qw & & \\qw & \\qw\\\\\n\\qw & \\gate{\\;\\;} & & \\qw & \\qw\\\\\n\\cw & \\cw & \\cw & \\cwbend{-5} & \\cw\\\\\n\\cw & \\cw & \\cwbend{-2} & \\cwbend{-1} & \\cw\n\\end{quantikz}"
@test circuit2string([ClassicalDecision(ibegin:iend,ibegin:iend)]) == circuit2string([ClassicalDecision(ibegin:iend,ibegin:iend)],mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\gate[1]{\\;\\;} & \\qw\\\\\n\\cw & \\cwbend{-1} & \\cw\n\\end{quantikz}"
circuit = [U(5),ClassicalDecision(ibegin:iend,2),ClassicalDecision(1,ibegin:iend)]
@test circuit2string(circuit) == circuit2string(circuit,mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\qw & \\gate[5,disable auto height]{\\;\\;} & \\gate[1]{\\;\\;} & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\qw & \\qw & \\qw & \\qw\\\\\n\\qw & \\gate{\\;\\;} & \\qw & \\qw & \\qw\\\\\n\\cw & \\cw & \\cw & \\cwbend{-5} & \\cw\\\\\n\\cw & \\cw & \\cwbend{-2} & \\cwbend{-1} & \\cw\n\\end{quantikz}"
circuit = [ClassicalDecision(ibegin:iend,ibegin:iend)]
@test circuit2string(circuit) == circuit2string(circuit,mode=:expanded) == "\\begin{quantikz}[transparent, row sep={0.8cm,between origins}]\n\\qw & \\gate[1]{\\;\\;} & \\qw\\\\\n\\cw & \\cwbend{-1} & \\cw\n\\end{quantikz}"
end

end
Expand Down

0 comments on commit 7532de6

Please sign in to comment.