Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Jul 11, 2023
1 parent b77eeb1 commit 9902d2d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/distributions/test_gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ import ReactiveMP: xtlog
end

@testset "rand" begin
rng = StableRNG(42)
for shape in (1, 2), scale in (1, 2)
for dist in (GammaShapeScale(shape, scale), GammaShapeRate(shape, inv(scale)))
rng = StableRNG(42)
dist1 = GammaShapeScale(shape, scale)
dist2 = GammaShapeRate(shape, inv(scale))

# Check that the result makes sense
for dist in (dist1, dist2)
@test rand(rng, dist) > 0.0
@test all(>(0.0), rand(rng, dist, 10))
@test all(>(0.0), rand!(rng, dist, Vector{Float64}(undef, 10)))
end

# Check that the result is almost identical and does not depend on the parametrisation
@test rand(StableRNG(42), dist1) rand(StableRNG(42), dist2)
@test all(rand(StableRNG(42), dist1, 10) .≈ rand(StableRNG(42), dist2, 10))
@test all(rand!(StableRNG(42), dist1, Vector{Float64}(undef, 10)) .≈ rand!(StableRNG(42), dist2, Vector{Float64}(undef, 10)))
end
end

Expand Down

0 comments on commit 9902d2d

Please sign in to comment.