allow specify parameter type in AffineDistribution#1769
Conversation
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
| # # TODO change @distr_support to generate functions that respect the type parameter | ||
| # minimum(::LogitNormal{T}) where T = T(0) | ||
| # maximum(::LogitNormal{T}) where T = T(1) |
There was a problem hiding this comment.
| # # TODO change @distr_support to generate functions that respect the type parameter | |
| # minimum(::LogitNormal{T}) where T = T(0) | |
| # maximum(::LogitNormal{T}) where T = T(1) |
| end | ||
|
|
||
| function AffineDistribution(μ::T, σ::T, ρ::UnivariateDistribution; check_args::Bool=true) where {T<:Real} | ||
| function AffineDistribution(μ::T, σ::T, ρ::UnivariateDistribution, _T::Type; check_args::Bool=true) where {T<:Real} |
There was a problem hiding this comment.
I'm not a fan of this approach - if users want to set the types specifically, they can just call one of the internal constructors.
Can't we just replace line 54 with
_T = promote_type(partype(ρ), T)BTW note that Type is one of the special cases where the Julia compiler does not specialize on the argument. If you want to specialize on the type, then you have to use ::Type{_T}.
There was a problem hiding this comment.
Thanks @devmotion for this aid.
I already tried making AffineTransformation using partype instead of eltype and it caused problems/failing tests with the discretenonparametric distribution.
I can prepare a pull request with the change and we can look, whether the failing discretenonparametric tests are reasonable (expecting rationals that are promoted to float with the change)
The deeper problem to me is that AffineTransformation transforms both, parameter-based quantities and samples. I think we should keep these two types separate (#1433)
second suggestion to workaround #1765