-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5560d9f
commit 2fd3bff
Showing
3 changed files
with
151 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Turing, Random, Bijectors | ||
using Distributions | ||
using Turing.RandomVariables | ||
using Test | ||
|
||
@testset "Common/Runners" begin | ||
@turing_testset "ComputeLogJointDensity" begin | ||
|
||
# Test assume with single random variable (unconstrained) | ||
vi = VarInfo() | ||
vn = VarName(gensym(), :x, "", 1) | ||
dist = Normal(0,1) | ||
r = rand(dist) | ||
gid = Turing.Selector() | ||
runner = Turing.ComputeLogJointDensity() | ||
|
||
push!(vi, vn, r, dist, gid) | ||
@test Turing.assume(runner, dist, vn, vi) == (r, logpdf(dist, r)) | ||
|
||
# Test assume with single random variable (constrained) | ||
vi = VarInfo() | ||
vn = VarName(gensym(), :x, "", 1) | ||
dist = Truncated(Normal(0,1), 0, Inf) | ||
r = link(dist, rand(dist)) | ||
gid = Turing.Selector() | ||
runner = Turing.ComputeLogJointDensity() | ||
|
||
push!(vi, vn, r, dist, gid) | ||
Turing.RandomVariables.settrans!(vi, true, vn) | ||
r_ = invlink(dist, r) | ||
@test Turing.assume(runner, dist, vn, vi) == (r_, logpdf_with_trans(dist, r_, true)) | ||
|
||
# Test observe with single random variable | ||
|
||
end | ||
end |