@@ -198,58 +198,6 @@ function DynamicPPL.tilde_assume(
198
198
end
199
199
end
200
200
201
- # Like the above tilde_assume methods, but with dot_tilde_assume and broadcasting of logpdf.
202
- # See comments there for more details.
203
- function DynamicPPL. dot_tilde_assume (context:: GibbsContext , right, left, vns, vi)
204
- child_context = DynamicPPL. childcontext (context)
205
- return if is_target_varname (context, vns)
206
- DynamicPPL. dot_tilde_assume (child_context, right, left, vns, vi)
207
- elseif has_conditioned_gibbs (context, vns)
208
- value, lp, _ = DynamicPPL. dot_tilde_assume (
209
- child_context, right, left, vns, get_global_varinfo (context)
210
- )
211
- value, lp, vi
212
- else
213
- value, lp, new_global_vi = DynamicPPL. dot_tilde_assume (
214
- child_context,
215
- DynamicPPL. SampleFromPrior (),
216
- right,
217
- left,
218
- vns,
219
- get_global_varinfo (context),
220
- )
221
- set_global_varinfo! (context, new_global_vi)
222
- value, lp, vi
223
- end
224
- end
225
-
226
- # As above but with an RNG.
227
- function DynamicPPL. dot_tilde_assume (
228
- rng:: Random.AbstractRNG , context:: GibbsContext , sampler, right, left, vns, vi
229
- )
230
- child_context = DynamicPPL. childcontext (context)
231
- return if is_target_varname (context, vns)
232
- DynamicPPL. dot_tilde_assume (rng, child_context, sampler, right, left, vns, vi)
233
- elseif has_conditioned_gibbs (context, vns)
234
- value, lp, _ = DynamicPPL. dot_tilde_assume (
235
- child_context, right, left, vns, get_global_varinfo (context)
236
- )
237
- value, lp, vi
238
- else
239
- value, lp, new_global_vi = DynamicPPL. dot_tilde_assume (
240
- rng,
241
- child_context,
242
- DynamicPPL. SampleFromPrior (),
243
- right,
244
- left,
245
- vns,
246
- get_global_varinfo (context),
247
- )
248
- set_global_varinfo! (context, new_global_vi)
249
- value, lp, vi
250
- end
251
- end
252
-
253
201
"""
254
202
make_conditional(model, target_variables, varinfo)
255
203
@@ -281,16 +229,8 @@ function make_conditional(
281
229
return DynamicPPL. contextualize (model, gibbs_context), gibbs_context_inner
282
230
end
283
231
284
- # All samplers are given the same Selector, so that they will sample all variables
285
- # given to them by the Gibbs sampler. This avoids conflicts between the new and the old way
286
- # of choosing which sampler to use.
287
- function set_selector (x:: DynamicPPL.Sampler )
288
- return DynamicPPL. Sampler (x. alg, DynamicPPL. Selector (0 ))
289
- end
290
- function set_selector (x:: RepeatSampler )
291
- return RepeatSampler (set_selector (x. sampler), x. num_repeat)
292
- end
293
- set_selector (x:: InferenceAlgorithm ) = DynamicPPL. Sampler (x, DynamicPPL. Selector (0 ))
232
+ wrap_in_sampler (x:: AbstractMCMC.AbstractSampler ) = x
233
+ wrap_in_sampler (x:: InferenceAlgorithm ) = DynamicPPL. Sampler (x)
294
234
295
235
to_varname_list (x:: Union{VarName,Symbol} ) = [VarName (x)]
296
236
# Any other value is assumed to be an iterable of VarNames and Symbols.
@@ -343,9 +283,7 @@ struct Gibbs{N,V<:NTuple{N,AbstractVector{<:VarName}},A<:NTuple{N,Any}} <:
343
283
end
344
284
end
345
285
346
- # Ensure that samplers have the same selector, and that varnames are lists of
347
- # VarNames.
348
- samplers = tuple (map (set_selector, samplers)... )
286
+ samplers = tuple (map (wrap_in_sampler, samplers)... )
349
287
varnames = tuple (map (to_varname_list, varnames)... )
350
288
return new {length(samplers),typeof(varnames),typeof(samplers)} (varnames, samplers)
351
289
end
0 commit comments