|
1 | 1 | using Test, Distributions, OffsetArrays |
2 | 2 |
|
3 | | -test_cgf(Gamma(1 ,1 ), (0.9, -1, -100f0, -1e6)) |
4 | | -test_cgf(Gamma(10 ,1 ), (0.9, -1, -100f0, -1e6)) |
5 | | -test_cgf(Gamma(0.2, 10), (0.08, -1, -100f0, -1e6)) |
| 3 | +@testset "Gamma" begin |
| 4 | + test_cgf(Gamma(1, 1), (0.9, -1, -100.0f0, -1e6)) |
| 5 | + test_cgf(Gamma(10, 1), (0.9, -1, -100.0f0, -1e6)) |
| 6 | + test_cgf(Gamma(0.2, 10), (0.08, -1, -100.0f0, -1e6)) |
6 | 7 |
|
7 | | -@testset "Gamma suffstats and OffsetArrays" begin |
8 | | - a = rand(Gamma(), 11) |
9 | | - wa = 1.0:11.0 |
| 8 | + @testset "Gamma suffstats and OffsetArrays" begin |
| 9 | + a = rand(Gamma(), 11) |
| 10 | + wa = 1.0:11.0 |
10 | 11 |
|
11 | | - resulta = @inferred(suffstats(Gamma, a)) |
| 12 | + resulta = @inferred(suffstats(Gamma, a)) |
12 | 13 |
|
13 | | - resultwa = @inferred(suffstats(Gamma, a, wa)) |
| 14 | + resultwa = @inferred(suffstats(Gamma, a, wa)) |
14 | 15 |
|
15 | | - b = OffsetArray(a, -5:5) |
16 | | - wb = OffsetArray(wa, -5:5) |
| 16 | + b = OffsetArray(a, -5:5) |
| 17 | + wb = OffsetArray(wa, -5:5) |
17 | 18 |
|
18 | | - resultb = @inferred(suffstats(Gamma, b)) |
19 | | - @test resulta == resultb |
| 19 | + resultb = @inferred(suffstats(Gamma, b)) |
| 20 | + @test resulta == resultb |
20 | 21 |
|
21 | | - resultwb = @inferred(suffstats(Gamma, b, wb)) |
22 | | - @test resultwa == resultwb |
| 22 | + resultwb = @inferred(suffstats(Gamma, b, wb)) |
| 23 | + @test resultwa == resultwb |
23 | 24 |
|
24 | | - @test_throws DimensionMismatch suffstats(Gamma, a, wb) |
| 25 | + @test_throws DimensionMismatch suffstats(Gamma, a, wb) |
| 26 | + end |
| 27 | + |
| 28 | + for T in (Float32, Float64) |
| 29 | + @test @inferred(rand(Gamma(T(1), T(1)))) isa T |
| 30 | + @test @inferred(rand(Gamma(1/T(2), T(1)))) isa T |
| 31 | + @test @inferred(rand(Gamma(T(2), T(1)))) isa T |
| 32 | + end |
25 | 33 | end |
0 commit comments