diff --git a/src/utils.jl b/src/utils.jl index aba431f70..f5a73e311 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -871,7 +871,6 @@ function varname_leaves(vn::VarName, val::NamedTuple) return Iterators.flatten(iter) end - """ varname_and_value_leaves(vn::VarName, val) @@ -918,10 +917,7 @@ julia> # `UpperTriangular` ``` """ function varname_and_value_leaves(vn::VarName, x) - return Iterators.map( - value, - Iterators.flatten(varname_and_value_leaves_inner(vn, x)) - ) + return Iterators.map(value, Iterators.flatten(varname_and_value_leaves_inner(vn, x))) end # Simple struct used to represent a varname-value pair even if we use @@ -947,18 +943,17 @@ function varname_and_value_leaves_inner( return ( Leaf( VarName(vn, DynamicPPL.getlens(vn) ∘ DynamicPPL.Setfield.IndexLens(Tuple(I))), - val[I] - ) - for I in CartesianIndices(val) + val[I], + ) for I in CartesianIndices(val) ) end # Containers. function varname_and_value_leaves_inner(vn::VarName, val::AbstractArray) return Iterators.flatten( varname_and_value_leaves_inner( - VarName(vn, DynamicPPL.getlens(vn) ∘ DynamicPPL.Setfield.IndexLens(Tuple(I))), val[I] - ) for - I in CartesianIndices(val) + VarName(vn, DynamicPPL.getlens(vn) ∘ DynamicPPL.Setfield.IndexLens(Tuple(I))), + val[I], + ) for I in CartesianIndices(val) ) end function varname_and_value_leaves_inner(vn::DynamicPPL.VarName, val::NamedTuple) @@ -978,7 +973,7 @@ function varname_and_value_leaves_inner(vn::VarName, x::LinearAlgebra.LowerTrian return ( Leaf( VarName(vn, DynamicPPL.getlens(vn) ∘ DynamicPPL.Setfield.IndexLens(Tuple(I))), - x[I] + x[I], ) # Iteration over the lower-triangular indices. for I in CartesianIndices(x) if I[1] >= I[2] @@ -988,7 +983,7 @@ function varname_and_value_leaves_inner(vn::VarName, x::LinearAlgebra.UpperTrian return ( Leaf( VarName(vn, DynamicPPL.getlens(vn) ∘ DynamicPPL.Setfield.IndexLens(Tuple(I))), - x[I] + x[I], ) # Iteration over the upper-triangular indices. for I in CartesianIndices(x) if I[1] <= I[2]