Skip to content

Commit

Permalink
Fix HierarchicalDistributions w/ dof smaller than length (#415)
Browse files Browse the repository at this point in the history
For some distributions length and dof do not coincide. This enables usage of i.e. Dirichlet distributions in HierarchicalDistributions
  • Loading branch information
waldie11 authored Jul 10, 2023
1 parent 01321f2 commit 1cc4f7a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/distributions/hierarchical_distribution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ ValueShapes.unshaped(d::HierarchicalDistribution) = UnshapedHDist(d)

Base.length(ud::UnshapedHDist) = length(ud.shaped)

eff_totalndof(d::UnshapedHDist) = eff_totalndof(d.shaped)

Base.eltype(ud::UnshapedHDist{VF,T}) where {VF,T} = T


Expand Down Expand Up @@ -187,7 +189,7 @@ end
=#

function _hd_split(ud::UnshapedHDist, x::AbstractVector{<:Real})
@argcheck length(ud) == length(eachindex(x))
@argcheck eff_totalndof(ud) == length(eachindex(x))
np = length(_hd_pridist(ud))
idxs = eachindex(x)
idxs_primary = first(idxs):(first(idxs) + np - 1)
Expand Down

0 comments on commit 1cc4f7a

Please sign in to comment.