Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
  • Loading branch information
sethaxen and devmotion authored Sep 4, 2024
1 parent f0dd8c4 commit 121dd2b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Matrixvariate = ArrayLikeVariate{2}
`F <: NamedTupleVariate{K}` specifies that the variate or a sample is of type
`NamedTuple{K}`.
"""
abstract type NamedTupleVariate{K} <: VariateForm end
struct NamedTupleVariate{K} <: VariateForm end

"""
`F <: CholeskyVariate` specifies that the variate or a sample is of type
Expand Down
4 changes: 2 additions & 2 deletions src/namedtuple/productnamedtuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function _gentype(d::Distribution{CholeskyVariate})
end
_gentype(::Distribution) = Any

_product_namedtuple_eltype(dists) = typejoin(map(_gentype, dists)...)
_product_namedtuple_eltype(dists::NamedTuple{K,V}) where {K,V} = __product_promote_type(eltype, V)

function Base.show(io::IO, d::ProductNamedTupleDistribution)
return show_multline(io, d, collect(pairs(d.dists)))
Expand Down Expand Up @@ -127,7 +127,7 @@ entropy(d::ProductNamedTupleDistribution) = sum(entropy, values(d.dists))
function kldivergence(
d1::ProductNamedTupleDistribution{K}, d2::ProductNamedTupleDistribution{K}
) where {K}
return mapreduce(kldivergence, +, d1.dists, d2.dists)
return sum(map(kldivergence, d1.dists, d2.dists))
end

# Sampling
Expand Down

0 comments on commit 121dd2b

Please sign in to comment.