-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Discrete valued dists expecting rand return of Union{int,BigInt}
- Loading branch information
1 parent
1ff41c2
commit 7c51d1f
Showing
9 changed files
with
39 additions
and
35 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const SafeInt = Union{Int, BigInt} | ||
|
||
""" | ||
A type to represent real-valued distributions, the purpose of this type is to avoid problems | ||
with the `eltype` function when having `rand` calls in the model. | ||
""" | ||
struct SafeIntValued <: Distributions.ValueSupport end | ||
function Base.eltype(::Type{<:Distributions.Sampleable{F, SafeIntValued}}) where {F} | ||
Union{Int, BigInt} | ||
end | ||
|
||
""" | ||
A constant alias for `Distribution{Univariate, RealValued}`. This type represents a univariate distribution with real-valued outcomes. | ||
""" | ||
const SafeDiscreteUnivariateDistribution = Distributions.Distribution{ | ||
Distributions.Univariate, SafeIntValued} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@testitem "SafeInt Type Tests" begin | ||
using Distributions | ||
struct DummySampleable <: Sampleable{Univariate, SafeIntValued} end | ||
|
||
@test SafeIntValued <: Distributions.ValueSupport | ||
@test eltype(DummySampleable) <: Union{Int, BigInt} | ||
@test SafeDiscreteUnivariateDistribution == Distribution{Univariate, SafeIntValued} | ||
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