Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Jul 11, 2023
1 parent 5728106 commit a234d1b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/distributions/test_gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ import ReactiveMP: xtlog
@test prod(ProdAnalytical(), GammaShapeRate(1, 2), GammaShapeScale(1, 2)) == GammaShapeRate(1, 5 / 2)
@test prod(ProdAnalytical(), GammaShapeRate(2, 2), GammaShapeScale(1, 2)) == GammaShapeRate(2, 5 / 2)
@test prod(ProdAnalytical(), GammaShapeRate(2, 2), GammaShapeScale(2, 2)) == GammaShapeRate(3, 5 / 2)

@test_throws AssertionError prod(ProdAnalytical(), GammaShapeRate(1, 1), Truncated(Normal(0.0, 1.0), -1.0, 1.0))
@test_throws AssertionError prod(ProdAnalytical(), Truncated(Normal(0.0, 1.0), -1.0, 1.0), GammaShapeRate(1, 1))
@test_throws AssertionError prod(ProdAnalytical(), GammaShapeScale(1, 1), Truncated(Normal(0.0, 1.0), -1.0, 1.0))
@test_throws AssertionError prod(ProdAnalytical(), Truncated(Normal(0.0, 1.0), -1.0, 1.0), GammaShapeScale(1, 1))

# TODO: these tests should check also check the actual result
@test prod(ProdAnalytical(), GammaShapeRate(1, 1), Truncated(Normal(0.0, 1.0), 0.0, Inf)) isa GammaShapeRate
@test prod(ProdAnalytical(), Truncated(Normal(0.0, 1.0), 0.0, Inf), GammaShapeRate(1, 1)) isa GammaShapeRate
@test prod(ProdAnalytical(), GammaShapeScale(1, 1), Truncated(Normal(0.0, 1.0), 0.0, Inf)) isa GammaShapeScale
@test prod(ProdAnalytical(), Truncated(Normal(0.0, 1.0), 0.0, Inf), GammaShapeScale(1, 1)) isa GammaShapeScale
end
end

Expand Down
7 changes: 7 additions & 0 deletions test/distributions/test_gamma_inverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ using Random
@test prod(ProdAnalytical(), GammaInverse(3.0, 2.0), GammaInverse(2.0, 1.0)) GammaInverse(6.0, 3.0)
@test prod(ProdAnalytical(), GammaInverse(7.0, 1.0), GammaInverse(0.1, 4.5)) GammaInverse(8.1, 5.5)
@test prod(ProdAnalytical(), GammaInverse(1.0, 3.0), GammaInverse(0.2, 0.4)) GammaInverse(2.2, 3.4)

@test_throws AssertionError prod(ProdAnalytical(), GammaInverse(1, 1), Truncated(Normal(0.0, 1.0), -1.0, 1.0))
@test_throws AssertionError prod(ProdAnalytical(), Truncated(Normal(0.0, 1.0), -1.0, 1.0), GammaInverse(1, 1))

# TODO: these tests should check also check the actual result
@test prod(ProdAnalytical(), GammaInverse(1, 1), Truncated(Normal(0.0, 1.0), 0.0, Inf)) isa GammaInverse
@test prod(ProdAnalytical(), Truncated(Normal(0.0, 1.0), 0.0, Inf), GammaInverse(1, 1)) isa GammaInverse
end

# log(θ) - digamma(α)
Expand Down

0 comments on commit a234d1b

Please sign in to comment.