Skip to content

Commit 0f58523

Browse files
committed
add missing test file
1 parent 18d8ff3 commit 0f58523

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/bijector.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
@testset "bijector.jl" begin
3+
@testset "bijector" begin
4+
@model function test()
5+
m ~ Normal()
6+
s ~ InverseGamma(3, 3)
7+
return c ~ Dirichlet([1.0, 1.0])
8+
end
9+
10+
m = test()
11+
b = bijector(m)
12+
13+
# m ∈ ℝ, s ∈ ℝ+, c ∈ 2-simplex
14+
# check dimensionalities and ranges
15+
@test b.length_in == 4
16+
@test b.length_out == 3
17+
@test b.ranges_in == [1:1, 2:2, 3:4]
18+
@test b.ranges_out == [1:1, 2:2, 3:3]
19+
@test b.ranges_out == [1:1, 2:2, 3:3]
20+
21+
# check support of mapped variables
22+
binv = inverse(b)
23+
zs = mapslices(binv, randn(b.length_out, 10000); dims=1)
24+
25+
@test all(zs[2, :] .≥ 0)
26+
@test all(sum(zs[3:4, :]; dims=1) .≈ 1.0)
27+
end
28+
end

0 commit comments

Comments
 (0)