Skip to content

Commit

Permalink
Apply some basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willtebbutt committed Nov 28, 2024
1 parent 88d132b commit 3877cf0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Bijectors = "76274a88-744f-5084-9051-94815aaf08c4"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c"
Expand Down
12 changes: 12 additions & 0 deletions test/logdensityfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ end
θ = varinfo[:]
@test LogDensityProblems.logdensity(logdensity, θ) logjoint(model, varinfo)
@test LogDensityProblems.dimension(logdensity) == length(θ)

# Test a single backend on the generic
# ADgradient(::AbstractADType, ::LogDensityFunction) method. This really just
# checks that it runs at all.
if varinfo isa DynamicPPL.TypedVarInfo
ad = ADTypes.AutoMooncake(; config=nothing)
∇ℓ = LogDensityProblemsAD.ADgradient(ad, logdensity)
@test isa(
LogDensityProblems.logdensity_and_gradient(∇ℓ, θ),
Tuple{Float64, Vector{Float64}},
)
end
end
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using DynamicPPL
using AbstractMCMC
using AbstractPPL
using Bijectors
using DifferentiationInterface
using Distributions
using DistributionsAD
using Documenter
Expand Down

0 comments on commit 3877cf0

Please sign in to comment.