-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inbounds Error Fixes for some Univariates (#1742)
* Inbounds Error Fixes for some Univariates Addresses #1265 - Fixed univariate normal - Fixed univariate gamma - Fixed poisson * Fixes some type instabilities * Update src/univariate/continuous/normal.jl Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * Update src/univariate/continuous/normal.jl Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * Update src/univariate/continuous/normal.jl Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * Update src/univariate/continuous/normal.jl Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * Update src/univariate/continuous/normal.jl Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * Fixes some type instabilities and adds tests - Fixes more type instabilities in normal - Adds tests for normal - Adds tests for gamma - Adds tests for poisson * Slight modifications in tests - Edited tests for normal - Edited tests for gamma - Edited tests for poisson * Update tests --------- Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
- Loading branch information
1 parent
dd876e7
commit 8f35aea
Showing
6 changed files
with
80 additions
and
17 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,3 +1,25 @@ | ||
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 suffstats and OffsetArrays" begin | ||
a = rand(Gamma(), 11) | ||
wa = 1.0:11.0 | ||
|
||
resulta = @inferred(suffstats(Gamma, a)) | ||
|
||
resultwa = @inferred(suffstats(Gamma, a, wa)) | ||
|
||
b = OffsetArray(a, -5:5) | ||
wb = OffsetArray(wa, -5:5) | ||
|
||
resultb = @inferred(suffstats(Gamma, b)) | ||
@test resulta == resultb | ||
|
||
resultwb = @inferred(suffstats(Gamma, b, wb)) | ||
@test resultwa == resultwb | ||
|
||
@test_throws DimensionMismatch suffstats(Gamma, a, wb) | ||
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
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,25 @@ | ||
using Test, Distributions, OffsetArrays | ||
|
||
test_cgf(Poisson(1 ), (1f0,2f0,10.0,50.0)) | ||
test_cgf(Poisson(10 ), (1f0,2f0,10.0,50.0)) | ||
test_cgf(Poisson(1e-3), (1f0,2f0,10.0,50.0)) | ||
|
||
@testset "Poisson suffstats and OffsetArrays" begin | ||
a = rand(Poisson(), 11) | ||
wa = 1.0:11.0 | ||
|
||
resulta = @inferred(suffstats(Poisson, a)) | ||
|
||
resultwa = @inferred(suffstats(Poisson, a, wa)) | ||
|
||
b = OffsetArray(a, -5:5) | ||
wb = OffsetArray(wa, -5:5) | ||
|
||
resultb = @inferred(suffstats(Poisson, b)) | ||
@test resulta == resultb | ||
|
||
resultwb = @inferred(suffstats(Poisson, b, wb)) | ||
@test resultwa == resultwb | ||
|
||
@test_throws DimensionMismatch suffstats(Poisson, a, wb) | ||
end |