Skip to content

Commit 989b648

Browse files
committed
Add docstrings to tilde_assume/_observe functions
1 parent 590780e commit 989b648

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/context_implementations.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ function tilde(ctx::MiniBatchContext, sampler, right, left::VarName, inds, vi)
3535
return tilde(ctx.ctx, sampler, right, left, inds, vi)
3636
end
3737

38+
"""
39+
tilde_assume(ctx, sampler, right, vn, inds, vi)
3840
41+
This method is applied in the generated code for assumed variables, e.g., `x ~ Normal()` where
42+
`x` does not occur in the model inputs.
43+
44+
Falls back to `tilde(ctx, sampler, right, vn, inds, vi)`.
45+
"""
3946
function tilde_assume(ctx, sampler, right, vn, inds, vi)
4047
return tilde(ctx, sampler, right, vn, inds, vi)
4148
end
@@ -74,9 +81,25 @@ function tilde(ctx::MiniBatchContext, sampler, right, left, vi)
7481
return ctx.loglike_scalar * tilde(ctx.ctx, sampler, right, left, vi)
7582
end
7683

84+
"""
85+
tilde_observe(ctx, sampler, right, left, vname, vinds, vi)
86+
87+
This method is applied in the generated code for observed variables, e.g., `x ~ Normal()` where
88+
`x` does occur the model inputs.
89+
90+
Falls back to `tilde(ctx, sampler, right, left, vi)` ignoring the information about variable
91+
name and indices; if needed, these can be accessed through this function, though.
92+
"""
7793
function tilde_observe(ctx, sampler, right, left, vname, vinds, vi)
7894
return tilde(ctx, sampler, right, left, vi)
7995
end
96+
97+
"""
98+
tilde_observe(ctx, sampler, right, left, vi)
99+
100+
This method is applied in the generated code for observed constants, e.g., `1.0 ~ Normal()`.
101+
Falls back to `tilde(ctx, sampler, right, left, vi)`.
102+
"""
80103
function tilde_observe(ctx, sampler, right, left, vi)
81104
return tilde(ctx, sampler, right, left, vi)
82105
end
@@ -177,6 +200,14 @@ function dot_tilde(
177200
return _dot_tilde(sampler, dist, left, vns, vi)
178201
end
179202

203+
"""
204+
dot_tilde_assume(ctx, sampler, right, left, vn, inds, vi)
205+
206+
This method is applied in the generated code for assumed vectorized variables, e.g., `x .~
207+
MvNormal()` where `x` does not occur in the model inputs.
208+
209+
Falls back to `dot_tilde(ctx, sampler, right, left, vn, inds, vi)`.
210+
"""
180211
function dot_tilde_assume(ctx, sampler, right, left, vn, inds, vi)
181212
return dot_tilde(ctx, sampler, right, left, vn, inds, vi)
182213
end
@@ -356,9 +387,25 @@ function dot_tilde(ctx::MiniBatchContext, sampler, right, left, vi)
356387
return ctx.loglike_scalar * dot_tilde(ctx.ctx, sampler, right, left, left, vi)
357388
end
358389

390+
"""
391+
dot_tilde_observe(ctx, sampler, right, left, vname, vinds, vi)
392+
393+
This method is applied in the generated code for vectorized observed variables, e.g., `x .~
394+
MvNormal()` where `x` does occur the model inputs.
395+
396+
Falls back to `dot_tilde(ctx, sampler, right, left, vi)` ignoring the information about variable
397+
name and indices; if needed, these can be accessed through this function, though.
398+
"""
359399
function dot_tilde_observe(ctx, sampler, right, left, vn, inds, vi)
360400
return dot_tilde(ctx, sampler, right, left, vi)
361401
end
402+
403+
"""
404+
dot_tilde_observe(ctx, sampler, right, left, vi)
405+
406+
This method is applied in the generated code for vectorized observed constants, e.g., `[1.0] .~
407+
MvNormal()`. Falls back to `dot_tilde(ctx, sampler, right, left, vi)`.
408+
"""
362409
function dot_tilde_observe(ctx, sampler, right, left, vi)
363410
return dot_tilde(ctx, sampler, right, left, vi)
364411
end

0 commit comments

Comments
 (0)