Skip to content

Commit

Permalink
Add tests for all Makie bang functions
Browse files Browse the repository at this point in the history
This also switches to using plain Makie. This should enable using Makie testing on CI.
  • Loading branch information
felixcremer committed Oct 13, 2023
1 parent a2da52e commit 3c45c98
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Aqua", "ArrayInterface", "BenchmarkTools", "Combinatorics", "CoordinateTransformations", "DataFrames", "Distributions", "Documenter", "ImageFiltering", "ImageTransformations", "OffsetArrays", "Plots", "Random", "SafeTestsets", "StatsPlots", "Test", "Unitful"]
test = ["Aqua", "ArrayInterface", "BenchmarkTools", "Combinatorics", "CoordinateTransformations", "DataFrames", "Distributions", "Documenter", "ImageFiltering", "ImageTransformations", "Makie", "OffsetArrays", "Plots", "Random", "SafeTestsets", "StatsPlots", "Test", "Unitful"]
153 changes: 100 additions & 53 deletions test/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,77 +159,124 @@ nothing

if !haskey(ENV, "CI")

using GLMakie
using Makie: Makie as M
@testset "Makie" begin
# 1d
A1 = rand(X('a':'e'); name=:test)
A1m = rand([missing, (1:3)...], X('a':'e'); name=:test)
A1m = rand([missing, (1:3.)...], X('a':'e'); name=:test)
A1m .= A1
A1m[3] = missing
plot(A1)
plot(A1m)
scatter(A1)
scatter(A1m)
lines(A1)
lines(A1m)
scatterlines(A1)
scatterlines(A1m)
stairs(A1)
stairs(A1m)
stem(A1)
stem(A1m)
barplot(A1)
barplot(A1m)
waterfall(A1)
waterfall(A1m)
fig, ax, _ = M.plot(A1)
M.plot!(ax, A1)
fig, ax, _ = M.plot(A1m)
M.plot!(ax, A1m)
fig, ax, _ = M.scatter(A1)
M.scatter!(ax, A1)
fig, ax, _ = M.scatter(A1m)
M.scatter!(ax, A1m)
fig, ax, _ = M.lines(A1)
M.lines!(ax, A1)
fig, ax, _ = M.lines(A1m)
M.lines!(ax, A1m)
fig, ax, _ = M.scatterlines(A1)
M.scatterlines!(ax, A1)
fig, ax, _ = M.scatterlines(A1m)
M.scatterlines!(ax, A1m)
fig, ax, _ = M.stairs(A1)
M.stairs!(ax, A1)
fig, ax, _ = M.stairs(A1m)
M.stairs!(ax, A1m)
fig, ax, _ = M.stem(A1)
M.stem!(ax, A1)
fig, ax, _ = M.stem(A1m)
M.stem!(ax, A1m)
fig, ax, _ = M.barplot(A1)
M.barplot!(ax, A1)
fig, ax, _ = M.barplot(A1m)
M.barplot!(ax, A1m)
fig, ax, _ = M.waterfall(A1)
M.waterfall!(ax, A1)
fig, ax, _ = M.waterfall(A1m)
M.waterfall!(ax, A1m)
# 2d
A2 = rand(X(10:10:100), Y(['a', 'b', 'c']))
A2r = rand(Y(10:10:100), X(['a', 'b', 'c']))
A2m = rand([missing, (1:5)...], Y(10:10:100), X(['a', 'b', 'c']))
A2m[3] = missing
plot(A2)
plot(A2m)
# Categorical wins: it's on x, even though its Y
boxplot(A2)
boxplot(A2r)
@test_throws ArgumentError boxplot(A2m)
violin(A2)
violin(A2r)
@test_throws ArgumentError violin(A2m)
rainclouds(A2)
@test_throws ErrorException rainclouds(A2m)
surface(A2)
surface(A2m)
fig, ax, _ = M.plot(A2)
M.plot!(ax, A2)
fig, ax, _ = M.plot(A2m)
M.plot!(ax, A2m)
fig, ax, _ = M.violin(A2r)
M.violin!(ax, A2r)
@test_throws ArgumentError M.violin(A2m)
@test_throws ArgumentError M.violin!(ax, A2m)

fig, ax, _ = M.rainclouds(A2)
M.rainclouds!(ax, A2)
@test_throws ErrorException M.rainclouds(A2m)
@test_throws ErrorException M.rainclouds!(ax, A2m)

fig, ax, _ = M.surface(A2)
M.surface!(ax, A2)
fig, ax, _ = M.surface(A2m)
M.surface!(ax, A2m)
# Series also puts Categories in the legend no matter where they are
series(A2)
series(A2r)
series(A2r; labeldim=Y)
series(A2m)
@test_throws ArgumentError plot(A2; y=:c)
fig, ax, _ = M.series(A2)
M.series!(ax, A2)
fig, ax, _ = M.series(A2r)
M.series!(ax, A2r)
fig, ax, _ = M.series(A2r; labeldim=Y)
M.series!(ax, A2r; labeldim=Y)
fig, ax, _ = M.series(A2m)
M.series!(ax, A2m)
@test_throws ArgumentError M.plot(A2; y=:c)
@test_throws ArgumentError M.plot!(ax, A2; y=:c)

# x/y can be specified
A2ab = DimArray(rand(6, 10), (:a, :b); name=:stuff)
plot(A2ab)
contourf(A2ab; x=:a)
heatmap(A2ab; y=:b)
series(A2ab)
boxplot(A2ab)
violin(A2ab)
rainclouds(A2ab)
surface(A2ab)
series(A2ab)
series(A2ab; labeldim=:a)
series(A2ab; labeldim=:b)
fig, ax, _ = M.plot(A2ab)
M.plot!(ax, A2ab)
fig, ax, _ = M.contourf(A2ab; x=:a)
M.contourf!(ax, A2ab, x=:a)
fig, ax, _ = M.heatmap(A2ab; y=:b)
M.heatmap!(ax, A2ab; y=:b)
fig, ax, _ = M.series(A2ab)
M.series!(ax, A2ab)
fig, ax, _ = M.boxplot(A2ab)
M.boxplot!(ax, A2ab)
fig, ax, _ = M.violin(A2ab)
M.violin!(A2ab)
fig, ax, _ = M.rainclouds(A2ab)
M.rainclouds!(A2ab)
fig, ax, _ = M.surface(A2ab)
M.surface!(ax, A2ab)
fig, ax, _ = M.series(A2ab)
M.series!(ax, A2ab)
fig, ax, _ = M.series(A2ab; labeldim=:a)
M.series!(ax, A2ab; labeldim=:a)
fig, ax, _ = M.series(A2ab; labeldim=:b)
M.series!(ax, A2ab;labeldim=:b)

# 3d
A3 = rand(X(7), Z(10), Y(5))
A3m = rand([missing, (1:7)...], X(7), Z(10), Y(5))
A3m[3] = missing
volume(A3)
volume(A3m)
volumeslices(A3)
volumeslices(A3m)
fig, ax, _ = M.volume(A3)
M.volume!(ax, A3)
fig, ax, _ = M.volume(A3m)
M.volume!(ax, A3m)
fig, ax, _ = M.volumeslices(A3)
M.volumeslices!(ax, A3)
fig, ax, _ = M.volumeslices(A3m)
M.volumeslices!(ax, A3m)
# x/y/z can be specified
A3abc = DimArray(rand(10, 10, 7), (:a, :b, :c); name=:stuff)
volume(A3abc; x=:c)
volumeslices(A3abc; z=:a)
fig, ax, _ = M.volume(A3abc; x=:c)
M.volumeslices(ax, A3abc; x=:c)
fig, ax, _ = M.volumeslices(A3abc; z=:a)
M.volumeslices!(ax, A3abc;z=:a)
end


end

0 comments on commit 3c45c98

Please sign in to comment.