@@ -285,17 +285,16 @@ function make_conditional(
285
285
return DynamicPPL. contextualize (model, gibbs_context), gibbs_context_inner
286
286
end
287
287
288
- wrap_algorithm_maybe (x) = x
289
- # All samplers are given the same Selector, so that they will also sample all variables
288
+ # All samplers are given the same Selector, so that they will sample all variables
290
289
# given to them by the Gibbs sampler. This avoids conflicts between the new and the old way
291
290
# of choosing which sampler to use.
292
- function wrap_algorithm_maybe (x:: DynamicPPL.Sampler )
291
+ function set_selector (x:: DynamicPPL.Sampler )
293
292
return DynamicPPL. Sampler (x. alg, DynamicPPL. Selector (0 ))
294
293
end
295
- function wrap_algorithm_maybe (x:: RepeatSampler )
296
- return RepeatSampler (wrap_algorithm_maybe (x. sampler), x. num_repeat)
294
+ function set_selector (x:: RepeatSampler )
295
+ return RepeatSampler (set_selector (x. sampler), x. num_repeat)
297
296
end
298
- wrap_algorithm_maybe (x:: InferenceAlgorithm ) = DynamicPPL. Sampler (x, DynamicPPL. Selector (0 ))
297
+ set_selector (x:: InferenceAlgorithm ) = DynamicPPL. Sampler (x, DynamicPPL. Selector (0 ))
299
298
300
299
"""
301
300
Gibbs
@@ -333,22 +332,17 @@ to_varname(t) = map(to_varname, collect(t))
333
332
# NamedTuple
334
333
Gibbs (; algs... ) = Gibbs (NamedTuple (algs))
335
334
function Gibbs (algs:: NamedTuple )
336
- return Gibbs (
337
- map (to_varname, keys (algs)), map (wrap_algorithm_maybe ∘ drop_space, values (algs))
338
- )
335
+ return Gibbs (map (to_varname, keys (algs)), map (set_selector ∘ drop_space, values (algs)))
339
336
end
340
337
341
338
# AbstractDict
342
339
function Gibbs (algs:: AbstractDict )
343
340
return Gibbs (
344
- map (to_varname, collect (keys (algs))),
345
- map (wrap_algorithm_maybe ∘ drop_space, values (algs)),
341
+ map (to_varname, collect (keys (algs))), map (set_selector ∘ drop_space, values (algs))
346
342
)
347
343
end
348
344
function Gibbs (algs:: Pair... )
349
- return Gibbs (
350
- map (to_varname ∘ first, algs), map (wrap_algorithm_maybe ∘ drop_space ∘ last, algs)
351
- )
345
+ return Gibbs (map (to_varname ∘ first, algs), map (set_selector ∘ drop_space ∘ last, algs))
352
346
end
353
347
354
348
# The below two constructors only provide backwards compatibility with the constructor of
@@ -372,7 +366,7 @@ function Gibbs(algs::InferenceAlgorithm...)
372
366
" `Gibbs(@varname(x) => RepeatSampler(NUTS(), 2), @varname(y) => MH())`"
373
367
)
374
368
Base. depwarn (msg, :Gibbs )
375
- return Gibbs (varnames, map (wrap_algorithm_maybe ∘ drop_space, algs))
369
+ return Gibbs (varnames, map (set_selector ∘ drop_space, algs))
376
370
end
377
371
378
372
function Gibbs (algs_with_iters:: Tuple{<:InferenceAlgorithm,Int} ...)
0 commit comments