Skip to content

Commit

Permalink
Update CairoMakie dependency and add CairoMakie extension tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoFioroni committed Dec 9, 2024
1 parent f0e35eb commit 801906a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ QuantumToolboxCairoMakieExt = "CairoMakie"
Aqua = "0.8"
ArrayInterface = "6, 7"
CUDA = "5"
CairoMakie = "0.12.15"
CairoMakie = "0.12"
DiffEqBase = "6"
DiffEqCallbacks = "4.2.1 - 4"
DiffEqNoiseProcess = "5"
Expand All @@ -65,8 +65,9 @@ julia = "1.10"

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

[targets]
test = ["Aqua", "JET", "Test"]
test = ["Aqua", "CairoMakie", "JET", "Test"]
63 changes: 63 additions & 0 deletions test/ext-test/cairomakie/cairomakie_ext.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@testset "CairoMakie Extension" verbose = true begin
ψ = normalize(coherent(50, 5.0) + coherent(50, -5.0))
xvec = yvec = -15.0:0.1:15.0
wig = wigner(ψ, xvec, yvec)'

@test_throws ArgumentError plot_wigner(ψ; library = :CairoMakie, xvec = xvec, yvec = yvec)

using CairoMakie

fig, ax, hm = plot_wigner(
ψ;
library = Val(:CairoMakie),
xvec = xvec,
yvec = yvec,
projection = Val(:two_dim),
colorbar = true,
)
@test fig isa Figure
@test ax isa Axis
@test hm isa Heatmap
@test all(isapprox.(hm[3].val, wig, atol = 1e-6))

fig, ax, surf = plot_wigner(
ψ;
library = Val(:CairoMakie),
xvec = xvec,
yvec = yvec,
projection = Val(:three_dim),
colorbar = true,
)
@test fig isa Figure
@test ax isa Axis3
@test surf isa Surface
@test all(isapprox.(surf[3].val, wig, atol = 1e-6))

fig = Figure()
pos = fig[2, 3]
fig1, ax, hm = plot_wigner(
ψ;
library = Val(:CairoMakie),
xvec = xvec,
yvec = yvec,
projection = Val(:two_dim),
colorbar = true,
location = pos,
)
@test fig1 === fig
@test fig[2, 3].layout.content[1].content[1, 1].layout.content[1].content === ax

fig = Figure()
pos = fig[2, 3]
fig1, ax, surf = plot_wigner(
ψ;
library = Val(:CairoMakie),
xvec = xvec,
yvec = yvec,
projection = Val(:three_dim),
colorbar = true,
location = pos,
)
@test fig1 === fig
@test fig[2, 3].layout.content[1].content[1, 1].layout.content[1].content === ax
end
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ core_tests = [
"wigner.jl",
]

ext_tests = [
joinpath("cairomakie", "cairomakie_ext.jl"),
]

if (GROUP == "All") || (GROUP == "Code-Quality")
using QuantumToolbox
using Aqua, JET
Expand All @@ -44,6 +48,10 @@ if (GROUP == "All") || (GROUP == "Core")
for test in core_tests
include(joinpath(testdir, "core-test", test))
end

for test in ext_tests
include(joinpath(testdir, "ext-test", test))
end
end

if (GROUP == "CUDA_Ext")# || (GROUP == "All")
Expand Down

0 comments on commit 801906a

Please sign in to comment.