Skip to content

Commit 82553ca

Browse files
LorenzoFioronialbertomercurio
authored andcommitted
Update CairoMakie dependency and add CairoMakie extension tests
1 parent 7abe438 commit 82553ca

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ QuantumToolboxCairoMakieExt = "CairoMakie"
3838
Aqua = "0.8"
3939
ArrayInterface = "6, 7"
4040
CUDA = "5"
41-
CairoMakie = "0.12.15"
41+
CairoMakie = "0.12"
4242
DiffEqBase = "6"
4343
DiffEqCallbacks = "4.2.1 - 4"
4444
DiffEqNoiseProcess = "5"
@@ -65,8 +65,9 @@ julia = "1.10"
6565

6666
[extras]
6767
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
68+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
6869
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
6970
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7071

7172
[targets]
72-
test = ["Aqua", "JET", "Test"]
73+
test = ["Aqua", "CairoMakie", "JET", "Test"]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
@testset "CairoMakie Extension" verbose = true begin
2+
ψ = normalize(coherent(50, 5.0) + coherent(50, -5.0))
3+
xvec = yvec = -15.0:0.1:15.0
4+
wig = wigner(ψ, xvec, yvec)'
5+
6+
@test_throws ArgumentError plot_wigner(ψ; library = :CairoMakie, xvec = xvec, yvec = yvec)
7+
8+
using CairoMakie
9+
10+
fig, ax, hm = plot_wigner(
11+
ψ;
12+
library = Val(:CairoMakie),
13+
xvec = xvec,
14+
yvec = yvec,
15+
projection = Val(:two_dim),
16+
colorbar = true,
17+
)
18+
@test fig isa Figure
19+
@test ax isa Axis
20+
@test hm isa Heatmap
21+
@test all(isapprox.(hm[3].val, wig, atol = 1e-6))
22+
23+
fig, ax, surf = plot_wigner(
24+
ψ;
25+
library = Val(:CairoMakie),
26+
xvec = xvec,
27+
yvec = yvec,
28+
projection = Val(:three_dim),
29+
colorbar = true,
30+
)
31+
@test fig isa Figure
32+
@test ax isa Axis3
33+
@test surf isa Surface
34+
@test all(isapprox.(surf[3].val, wig, atol = 1e-6))
35+
36+
fig = Figure()
37+
pos = fig[2, 3]
38+
fig1, ax, hm = plot_wigner(
39+
ψ;
40+
library = Val(:CairoMakie),
41+
xvec = xvec,
42+
yvec = yvec,
43+
projection = Val(:two_dim),
44+
colorbar = true,
45+
location = pos,
46+
)
47+
@test fig1 === fig
48+
@test fig[2, 3].layout.content[1].content[1, 1].layout.content[1].content === ax
49+
50+
fig = Figure()
51+
pos = fig[2, 3]
52+
fig1, ax, surf = plot_wigner(
53+
ψ;
54+
library = Val(:CairoMakie),
55+
xvec = xvec,
56+
yvec = yvec,
57+
projection = Val(:three_dim),
58+
colorbar = true,
59+
location = pos,
60+
)
61+
@test fig1 === fig
62+
@test fig[2, 3].layout.content[1].content[1, 1].layout.content[1].content === ax
63+
end

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ core_tests = [
2626
"wigner.jl",
2727
]
2828

29+
ext_tests = [
30+
joinpath("cairomakie", "cairomakie_ext.jl"),
31+
]
32+
2933
if (GROUP == "All") || (GROUP == "Code-Quality")
3034
using QuantumToolbox
3135
using Aqua, JET
@@ -44,6 +48,10 @@ if (GROUP == "All") || (GROUP == "Core")
4448
for test in core_tests
4549
include(joinpath(testdir, "core-test", test))
4650
end
51+
52+
for test in ext_tests
53+
include(joinpath(testdir, "ext-test", test))
54+
end
4755
end
4856

4957
if (GROUP == "CUDA_Ext")# || (GROUP == "All")

0 commit comments

Comments
 (0)