-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue 492: Create distribution that returns
<: Union{Int,BigInt}
(#497
) * Make RealUnivariateDistribution type * test RealUnivariateDistribution * update method * reformat * modify procf * Explicit use of Distributions * fix unit test fails * Discrete valued dists expecting rand return of Union{int,BigInt} * Make RealUnivariateDistribution type * test RealUnivariateDistribution * update method * reformat * modify procf * Explicit use of Distributions * fix unit test fails * Discrete valued dists expecting rand return of Union{int,BigInt} * Typo * Revert CI test --------- Co-authored-by: Sam Abbott <[email protected]>
- Loading branch information
1 parent
119f244
commit 0b6a162
Showing
9 changed files
with
39 additions
and
14 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
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} | ||
SafeInt | ||
end | ||
|
||
""" | ||
A constant alias for `Distribution{Univariate, SafeIntValued}`. 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 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
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