-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Categorical cannot take abstract array p #1084
Comments
You can bypass the check with |
+1 to this. the error is hard to make sense of also |
Just got bitten by this... The issue is that in the constructor for Distributions.jl/src/univariate/discrete/discretenonparametric.jl Lines 33 to 34 in a1010e4
The return type of I don't think it's a good idea to make IMO a better approach here is to ensure that the constructor for
implies that function DiscreteNonParametric{T,P,Ts,Ps}(xs::Ts, ps::Ps; check_args::Bool=true) where {
T<:Integer,P<:Real,Ts<:Base.OneTo{T},Ps<:AbstractVector{P}}
check_args || return DiscreteNonParametric{T,P,Ts,Ps}(xs, ps, check_args = false)
@check_args(
DiscreteNonParametric,
(length(xs) == length(ps), "length of support and probability vector must be equal"),
(ps, isprobvec(ps), "vector is not a probability vector")
)
return DiscreteNonParametric{T,P,Ts,Ps}(xs, ps, check_args = false)
end I'd be happy to open a PR! |
For example:
Then:
Cannot
Categorical(p)
admit genericAbstractVector
as argumentp
?The text was updated successfully, but these errors were encountered: