From eb9b2e0d60ef3dd85768d6e6a9f19de15b8f7130 Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Sat, 29 Jul 2023 00:54:06 +0100 Subject: [PATCH] Fix duplicate of include and some bugs in tests (#343) * Fix duplicate include of common.jl * Bugfix. * bump version * Bugfix --- Project.toml | 2 +- test/abstractmcmc.jl | 1 - test/constructors.jl | 9 ++++----- test/contrib.jl | 2 -- test/cuda.jl | 2 -- test/hamiltonian.jl | 3 --- test/integrator.jl | 1 - test/mcmcchains.jl | 1 - test/models.jl | 2 -- test/runtests.jl | 3 +++ test/sampler-vec.jl | 1 - test/sampler.jl | 1 - test/trajectory.jl | 1 - 13 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Project.toml b/Project.toml index 7e006f1b..f98be0f0 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "AdvancedHMC" uuid = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d" -version = "0.5.2" +version = "0.5.3" [deps] AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001" diff --git a/test/abstractmcmc.jl b/test/abstractmcmc.jl index 52d6c35c..4d895c72 100644 --- a/test/abstractmcmc.jl +++ b/test/abstractmcmc.jl @@ -1,6 +1,5 @@ using ReTest, Random, AdvancedHMC, ForwardDiff, AbstractMCMC using Statistics: mean -include("common.jl") @testset "AbstractMCMC w/ gdemo" begin rng = MersenneTwister(0) diff --git a/test/constructors.jl b/test/constructors.jl index 8d66a79e..49b0cf89 100644 --- a/test/constructors.jl +++ b/test/constructors.jl @@ -1,5 +1,4 @@ using AdvancedHMC, AbstractMCMC, Random -include("common.jl") get_kernel_hyperparams(spl::HMC, state) = state.κ.τ.termination_criterion.L get_kernel_hyperparams(spl::HMCDA, state) = state.κ.τ.termination_criterion.λ @@ -169,13 +168,13 @@ end spl = NUTS(0.8) T = AdvancedHMC.sampler_eltype(spl) - metric = make_metric(spl, logdensity) + metric = AdvancedHMC.make_metric(spl, logdensity) hamiltonian = Hamiltonian(metric, model) - init_params1 = make_init_params(rng, spl, logdensity, nothing) + init_params1 = AdvancedHMC.make_init_params(rng, spl, logdensity, nothing) @test typeof(init_params1) == Vector{T} @test length(init_params1) == d - init_params2 = make_init_params(rng, spl, logdensity, θ_init) - @test init_params2 === θ_init + init_params2 = AdvancedHMC.make_init_params(rng, spl, logdensity, θ_init) + @test init_params2 == θ_init end end diff --git a/test/contrib.jl b/test/contrib.jl index 1bba01fb..38a5023a 100644 --- a/test/contrib.jl +++ b/test/contrib.jl @@ -1,7 +1,5 @@ using ReTest, AdvancedHMC, ForwardDiff, Zygote -include("common.jl") - @testset "contrib" begin @testset "ad" begin metric = UnitEuclideanMetric(D) diff --git a/test/cuda.jl b/test/cuda.jl index fb9655a9..39c02f92 100644 --- a/test/cuda.jl +++ b/test/cuda.jl @@ -4,8 +4,6 @@ using AdvancedHMC: DualValue, PhasePoint using CUDA @testset "AdvancedHMC GPU" begin - include("common.jl") - n_chains = 1000 n_samples = 1000 dim = 5 diff --git a/test/hamiltonian.jl b/test/hamiltonian.jl index 91607280..47948325 100644 --- a/test/hamiltonian.jl +++ b/test/hamiltonian.jl @@ -2,9 +2,6 @@ using ReTest, AdvancedHMC using AdvancedHMC: GaussianKinetic, DualValue, PhasePoint using LinearAlgebra: dot, diagm - -include("common.jl") - @testset "Hamiltonian" begin f = x -> dot(x, x) g = x -> 2x diff --git a/test/integrator.jl b/test/integrator.jl index 00582034..672b480e 100644 --- a/test/integrator.jl +++ b/test/integrator.jl @@ -1,5 +1,4 @@ using ReTest, Random, AdvancedHMC, ForwardDiff -include("common.jl") using OrdinaryDiffEq using LinearAlgebra: dot diff --git a/test/mcmcchains.jl b/test/mcmcchains.jl index 1c896884..a555a90a 100644 --- a/test/mcmcchains.jl +++ b/test/mcmcchains.jl @@ -1,6 +1,5 @@ using ReTest, Random, AdvancedHMC, ForwardDiff, AbstractMCMC, MCMCChains using Statistics: mean -include("common.jl") @testset "MCMCChains w/ gdemo" begin rng = MersenneTwister(0) diff --git a/test/models.jl b/test/models.jl index 08be9197..cdff6ef3 100644 --- a/test/models.jl +++ b/test/models.jl @@ -1,7 +1,5 @@ using ReTest, Random, AdvancedHMC, ForwardDiff using Statistics: mean -include("common.jl") - @testset "Models" begin @testset "gdemo" begin diff --git a/test/runtests.jl b/test/runtests.jl index 0a58c56a..382bb871 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,7 @@ using FillArrays using AdvancedHMC: AdvancedHMC using LogDensityProblems: LogDensityProblems using LogDensityProblemsAD: LogDensityProblemsAD +using ReTest println("Environment variables for testing") println(ENV) @@ -11,6 +12,8 @@ const DIRECTORY_AdvancedHMC = dirname(dirname(pathof(AdvancedHMC))) const DIRECTORY_Turing_tests = joinpath(DIRECTORY_AdvancedHMC, "test", "turing") const GROUP = get(ENV, "AHMC_TEST_GROUP", "AdvancedHMC") +include("common.jl") + if GROUP == "All" || GROUP == "AdvancedHMC" using ReTest, CUDA diff --git a/test/sampler-vec.jl b/test/sampler-vec.jl index 2b85614a..b629c538 100644 --- a/test/sampler-vec.jl +++ b/test/sampler-vec.jl @@ -1,6 +1,5 @@ using ReTest, AdvancedHMC, LinearAlgebra, UnicodePlots, Random using Statistics: mean, var, cov -include("common.jl") @testset "sample (vectorized)" begin n_chains_max = 20 diff --git a/test/sampler.jl b/test/sampler.jl index 94b32122..109f01a4 100644 --- a/test/sampler.jl +++ b/test/sampler.jl @@ -6,7 +6,6 @@ using AdvancedHMC: StaticTerminationCriterion, DynamicTerminationCriterion using Setfield using Statistics: mean, var, cov unicodeplots() -include("common.jl") function test_stats( ::Trajectory{TS,I,TC}, diff --git a/test/trajectory.jl b/test/trajectory.jl index 06da7399..2ff8acbe 100644 --- a/test/trajectory.jl +++ b/test/trajectory.jl @@ -1,7 +1,6 @@ using ReTest, AdvancedHMC, Random using Statistics: mean using LinearAlgebra: dot -include("common.jl") function makeplot(plt, traj_θ, ts_list...) function plotturn!(traj_θ, ts)