-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix type stability of sampling from `Chisq`, `TDist`, `Gamma` * fix remove type specification in `rand(Exponential)` Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * fix type specificaton in `rand(TDist)` Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * fix remove type test for `rand(Chisq)` * fix make `Exponential` use the `Normal` sampling type policy * fix missing type signature * fix type signature for `rand(Exponential)` Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * fix use `@inferred` in tests for `Gamma` Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * fix use `@inferred` in tests for `TDist` Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * add type stability tests for `rand(Exponential)` * add type stability test for `rand(Chisq)` * fix remove type stability test for `entropy(TDist)` (not stable) --------- Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
- Loading branch information
1 parent
13029c0
commit 3946acc
Showing
7 changed files
with
56 additions
and
28 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
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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
test_cgf(Chisq(1), (0.49, -1, -100, -1f6)) | ||
test_cgf(Chisq(3), (0.49, -1, -100, -1f6)) | ||
|
||
@testset "Chisq" begin | ||
test_cgf(Chisq(1), (0.49, -1, -100, -1.0f6)) | ||
test_cgf(Chisq(3), (0.49, -1, -100, -1.0f6)) | ||
|
||
for T in (Float32, Float64) | ||
@test @inferred(rand(Chisq(T(1)))) isa T | ||
end | ||
end |
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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
|
||
test_cgf(Exponential(1), (0.9, -1, -100f0, -1e6)) | ||
test_cgf(Exponential(0.91), (0.9, -1, -100f0, -1e6)) | ||
test_cgf(Exponential(10 ), (0.08, -1, -100f0, -1e6)) | ||
@testset "Exponential" begin | ||
test_cgf(Exponential(1), (0.9, -1, -100f0, -1e6)) | ||
test_cgf(Exponential(0.91), (0.9, -1, -100f0, -1e6)) | ||
test_cgf(Exponential(10 ), (0.08, -1, -100f0, -1e6)) | ||
|
||
for T in (Float32, Float64) | ||
@test @inferred(rand(Exponential(T(1)))) isa T | ||
end | ||
end |
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 |
---|---|---|
@@ -1,25 +1,33 @@ | ||
using Test, Distributions, OffsetArrays | ||
|
||
test_cgf(Gamma(1 ,1 ), (0.9, -1, -100f0, -1e6)) | ||
test_cgf(Gamma(10 ,1 ), (0.9, -1, -100f0, -1e6)) | ||
test_cgf(Gamma(0.2, 10), (0.08, -1, -100f0, -1e6)) | ||
@testset "Gamma" begin | ||
test_cgf(Gamma(1, 1), (0.9, -1, -100.0f0, -1e6)) | ||
test_cgf(Gamma(10, 1), (0.9, -1, -100.0f0, -1e6)) | ||
test_cgf(Gamma(0.2, 10), (0.08, -1, -100.0f0, -1e6)) | ||
|
||
@testset "Gamma suffstats and OffsetArrays" begin | ||
a = rand(Gamma(), 11) | ||
wa = 1.0:11.0 | ||
@testset "Gamma suffstats and OffsetArrays" begin | ||
a = rand(Gamma(), 11) | ||
wa = 1.0:11.0 | ||
|
||
resulta = @inferred(suffstats(Gamma, a)) | ||
resulta = @inferred(suffstats(Gamma, a)) | ||
|
||
resultwa = @inferred(suffstats(Gamma, a, wa)) | ||
resultwa = @inferred(suffstats(Gamma, a, wa)) | ||
|
||
b = OffsetArray(a, -5:5) | ||
wb = OffsetArray(wa, -5:5) | ||
b = OffsetArray(a, -5:5) | ||
wb = OffsetArray(wa, -5:5) | ||
|
||
resultb = @inferred(suffstats(Gamma, b)) | ||
@test resulta == resultb | ||
resultb = @inferred(suffstats(Gamma, b)) | ||
@test resulta == resultb | ||
|
||
resultwb = @inferred(suffstats(Gamma, b, wb)) | ||
@test resultwa == resultwb | ||
resultwb = @inferred(suffstats(Gamma, b, wb)) | ||
@test resultwa == resultwb | ||
|
||
@test_throws DimensionMismatch suffstats(Gamma, a, wb) | ||
@test_throws DimensionMismatch suffstats(Gamma, a, wb) | ||
end | ||
|
||
for T in (Float32, Float64) | ||
@test @inferred(rand(Gamma(T(1), T(1)))) isa T | ||
@test @inferred(rand(Gamma(1/T(2), T(1)))) isa T | ||
@test @inferred(rand(Gamma(T(2), T(1)))) isa T | ||
end | ||
end |
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