Skip to content

Commit d22df39

Browse files
committed
Rename a function in Gibbs
1 parent d17e6ed commit d22df39

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/mcmc/gibbs.jl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,16 @@ function make_conditional(
285285
return DynamicPPL.contextualize(model, gibbs_context), gibbs_context_inner
286286
end
287287

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
290289
# given to them by the Gibbs sampler. This avoids conflicts between the new and the old way
291290
# of choosing which sampler to use.
292-
function wrap_algorithm_maybe(x::DynamicPPL.Sampler)
291+
function set_selector(x::DynamicPPL.Sampler)
293292
return DynamicPPL.Sampler(x.alg, DynamicPPL.Selector(0))
294293
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)
297296
end
298-
wrap_algorithm_maybe(x::InferenceAlgorithm) = DynamicPPL.Sampler(x, DynamicPPL.Selector(0))
297+
set_selector(x::InferenceAlgorithm) = DynamicPPL.Sampler(x, DynamicPPL.Selector(0))
299298

300299
"""
301300
Gibbs
@@ -333,22 +332,17 @@ to_varname(t) = map(to_varname, collect(t))
333332
# NamedTuple
334333
Gibbs(; algs...) = Gibbs(NamedTuple(algs))
335334
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)))
339336
end
340337

341338
# AbstractDict
342339
function Gibbs(algs::AbstractDict)
343340
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))
346342
)
347343
end
348344
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))
352346
end
353347

354348
# The below two constructors only provide backwards compatibility with the constructor of
@@ -372,7 +366,7 @@ function Gibbs(algs::InferenceAlgorithm...)
372366
"`Gibbs(@varname(x) => RepeatSampler(NUTS(), 2), @varname(y) => MH())`"
373367
)
374368
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))
376370
end
377371

378372
function Gibbs(algs_with_iters::Tuple{<:InferenceAlgorithm,Int}...)

0 commit comments

Comments
 (0)