From 4f1884997929b0d3de987aa23cdb9e1b5c7f8c4d Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 11 Aug 2025 22:17:25 +0200 Subject: [PATCH 1/3] Remove test dependency on Plots --- Project.toml | 2 +- test/Project.toml | 2 -- test/common.jl | 9 ++------- test/sampler-vec.jl | 25 ++++++++----------------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/Project.toml b/Project.toml index 443e34b2d..180782588 100644 --- a/Project.toml +++ b/Project.toml @@ -48,7 +48,7 @@ Setfield = "0.7, 0.8, 1" Statistics = "1.6" StatsBase = "0.31, 0.32, 0.33, 0.34" StatsFuns = "0.8, 0.9, 1" -julia = "1.10.2" +julia = "1.10" [extras] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/test/Project.toml b/test/Project.toml index 558e3d43d..5b5191c46 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -14,13 +14,11 @@ LogDensityProblemsAD = "996a588d-648d-4e1f-a8f0-a84b347e47b1" MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ReTest = "e0db7c4e-2690-44b9-bad6-7687da720f89" Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] diff --git a/test/common.jl b/test/common.jl index 5be97190e..32f7a04da 100644 --- a/test/common.jl +++ b/test/common.jl @@ -109,10 +109,5 @@ function LogDensityProblems.capabilities(::Type{typeof(ℓπ_gdemo)}) return LogDensityProblems.LogDensityOrder{0}() end -test_show(x) = test_show(s -> length(s) > 0, x) -function test_show(pred, x) - io = IOBuffer(; append=true) - show(io, x) - s = read(io, String) - @test pred(s) -end +test_show(x) = test_show(!isempty, x) +test_show(pred, x) = @test pred(repr(x)) diff --git a/test/sampler-vec.jl b/test/sampler-vec.jl index da2cfff12..7b9f9b1e4 100644 --- a/test/sampler-vec.jl +++ b/test/sampler-vec.jl @@ -1,4 +1,4 @@ -using ReTest, AdvancedHMC, LinearAlgebra, UnicodePlots, Random +using ReTest, AdvancedHMC, LinearAlgebra, Random using Statistics: mean, var, cov @testset "sample (vectorized)" begin @@ -95,7 +95,7 @@ using Statistics: mean, var, cov end # Time for multiple runs of single chain - time_seperate = Vector{Float64}(undef, n_chains_max) + time_separate = Vector{Float64}(undef, n_chains_max) for (i, n_chains) in enumerate(n_chains_list) t = @elapsed for j in 1:n_chains @@ -104,22 +104,13 @@ using Statistics: mean, var, cov h, κ, θ_init_list[i][:, j], n_samples; verbose=false ) end - time_seperate[i] = t + time_separate[i] = t end - # Make plot - fig = lineplot( - collect(1:n_chains_max), - time_mat; - title="Scalabiliry of multiple chains", - name="vectorization", - xlabel="Num of chains", - ylabel="Time (s)", - ) - lineplot!(fig, collect(n_chains_list), time_seperate; color=:blue, name="seperate") - println() - show(fig) - println() - println() + println("\nVectorized vs separate sampling") + println(" number of chains: ", n_chains_list) + println(" elapsed time [s] (vectorized): ", round.(time_mat; sigdigits=2)) + println(" elapsed time [s] (separate): ", round.(time_separate; sigdigits=2)) + println(" ratio of elapsed time: ", round.(time_separate ./ time_mat; sigdigits=2)) end end From ad1d79776fadfda3dec9da8cd41f9e23c457b3dc Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 11 Aug 2025 20:21:49 +0000 Subject: [PATCH 2/3] Update test/sampler-vec.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/sampler-vec.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/sampler-vec.jl b/test/sampler-vec.jl index 7b9f9b1e4..83c612d88 100644 --- a/test/sampler-vec.jl +++ b/test/sampler-vec.jl @@ -111,6 +111,9 @@ using Statistics: mean, var, cov println(" number of chains: ", n_chains_list) println(" elapsed time [s] (vectorized): ", round.(time_mat; sigdigits=2)) println(" elapsed time [s] (separate): ", round.(time_separate; sigdigits=2)) - println(" ratio of elapsed time: ", round.(time_separate ./ time_mat; sigdigits=2)) + println( + " ratio of elapsed time: ", + round.(time_separate ./ time_mat; sigdigits=2), + ) end end From 89058e3e9eb49d591f814c427a7b13a461f0e7aa Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 11 Aug 2025 21:01:39 +0000 Subject: [PATCH 3/3] Remove imports --- test/sampler.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/sampler.jl b/test/sampler.jl index 919edd9c7..0c9e4e3de 100644 --- a/test/sampler.jl +++ b/test/sampler.jl @@ -1,11 +1,10 @@ # Allow pass --progress when running this script individually to turn on progress meter const PROGRESS = length(ARGS) > 0 && ARGS[1] == "--progress" ? true : false -using ReTest, AdvancedHMC, LinearAlgebra, Random, Plots +using ReTest, AdvancedHMC, LinearAlgebra, Random using AdvancedHMC: StaticTerminationCriterion, DynamicTerminationCriterion using Setfield using Statistics: mean, var, cov -unicodeplots() function test_stats( ::Trajectory{TS,I,TC}, stats, n_adapts