@@ -90,6 +90,21 @@ left-hand side of a `.~` expression such as `x .~ Normal()`.
90
90
91
91
This is used mainly to unwrap `NamedDist` distributions and adjust the indices of the
92
92
variables.
93
+
94
+ # Example
95
+ ```jldoctest; setup=:(using Distributions)
96
+ julia> _, _, vns = DynamicPPL.unwrap_right_left_vns(MvNormal(1, 1.0), randn(1, 2), @varname(x)); string(vns[end])
97
+ "x[:,2]"
98
+
99
+ julia> _, _, vns = DynamicPPL.unwrap_right_left_vns(Normal(), randn(1, 2), @varname(x[:])); string(vns[end])
100
+ "x[:][1,2]"
101
+
102
+ julia> _, _, vns = DynamicPPL.unwrap_right_left_vns(Normal(), randn(3), @varname(x[1])); string(vns[end])
103
+ "x[1][3]"
104
+
105
+ julia> _, _, vns = DynamicPPL.unwrap_right_left_vns(Normal(), randn(1, 2, 3), @varname(x)); string(vns[end])
106
+ "x[1,2,3]"
107
+ ```
93
108
"""
94
109
unwrap_right_left_vns (right, left, vns) = right, left, vns
95
110
function unwrap_right_left_vns (right:: NamedDist , left, vns)
@@ -103,7 +118,7 @@ function unwrap_right_left_vns(
103
118
# for `i = size(left, 2)`. Hence the symbol should be `x[:, i]`,
104
119
# and we therefore add the `Colon()` below.
105
120
vns = map (axes (left, 2 )) do i
106
- return VarName (vn, (vn. indexing... , Colon (), Tuple ( i)))
121
+ return VarName (vn, (vn. indexing... , ( Colon (), i)))
107
122
end
108
123
return unwrap_right_left_vns (right, left, vns)
109
124
end
0 commit comments