Skip to content

Commit

Permalink
Add a test for getstepsize()
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Nov 29, 2024
1 parent 406c2ad commit c86a34e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/mcmc/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,25 @@ using Turing
@test pvalue(ApproximateTwoSampleKSTest(vec(results), vec(results_prior))) > 0.001
end

@testset "getstepsize: Turing.jl#2400" begin
algs = [
HMC(0.1, 10),
HMCDA(0.8, 0.75),
NUTS(0.5),
NUTS(0, 0.5),
]
@testset "$(alg)" for alg in algs
spl = Sampler(alg, gdemo_default)
hmc_state = DynamicPPL.initialstep(
Random.default_rng(),
gdemo_default,
spl,
DynamicPPL.VarInfo(gdemo_default)
)[2]
@test Turing.Inference.getstepsize(spl, hmc_state) isa Float64
end
end

@testset "Check ADType" begin
alg = HMC(0.1, 10; adtype=adbackend)
m = DynamicPPL.contextualize(
Expand Down

0 comments on commit c86a34e

Please sign in to comment.