-
Notifications
You must be signed in to change notification settings - Fork 1
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
Generalize pointmasses for abstractarray #19
Conversation
src/densities/pointmass.jl
Outdated
function Base.precision(distribution::PointMass{V}) where {T<:Real,V<:AbstractVector{T}} | ||
return one(T) ./ cov(distribution) | ||
function BayesBase.cov(distribution::PointMass{M}) where {T<:Real,N,M<:AbstractArray{T,N}} | ||
return error("cov(::PointMass{ <: AbstractMatrix }) is not defined") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error mentions AbstractMatrix
, but accepts arbitrary AbstractArray
src/densities/pointmass.jl
Outdated
function BayesBase.probvec( | ||
distribution::PointMass{M} | ||
) where {T<:Real,N,M<:AbstractArray{T,N}} | ||
return error("probvec(::PointMass{ <: AbstractMatrix }) is not defined") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments, otherwise seems legit
Just as a side note, perhaps we should somehow rewrite PointMass to allow literally any object, but some may or may not support all operations, which can be determined by a trait-based system. This way we could close the #10 |
Basically what the PR title says. I'm not sure about
Base.ndims
for vectors now. I implemented it separately now for backwards compatibility but it seems that it is only used instd
andvar
and can therefore also just work with the generic implementation.