239239Update all the accumulators of `vi` by calling `accumulate_assume!!` on them.
240240"""
241241function accumulate_assume!! (vi:: AbstractVarInfo , val, logjac, vn, right)
242- return map_accumulator !! (vi, accumulate_assume!!, val, logjac, vn, right)
242+ return map_accumulators !! (acc -> accumulate_assume!! (acc , val, logjac, vn, right), vi )
243243end
244244
245245"""
@@ -248,37 +248,35 @@ end
248248Update all the accumulators of `vi` by calling `accumulate_observe!!` on them.
249249"""
250250function accumulate_observe!! (vi:: AbstractVarInfo , right, left, vn)
251- return map_accumulator !! (vi, accumulate_observe!!, right, left, vn)
251+ return map_accumulators !! (acc -> accumulate_observe!! (acc , right, left, vn), vi )
252252end
253253
254254"""
255- map_accumulator!! (vi::AbstractVarInfo, func::Function, args...) where {accname}
255+ map_accumulators (vi::AbstractVarInfo, func::Function)
256256
257- Update all accumulators of `vi` by calling `func(acc, args...) ` on them and replacing
258- them with the return values.
257+ Update all accumulators of `vi` by calling `func` on them and replacing them with the return
258+ values.
259259"""
260- function map_accumulator !! (vi :: AbstractVarInfo , func:: Function , args ... )
261- return setaccs!! (vi, map_accumulator!! ( getaccs (vi), func, args ... ))
260+ function map_accumulators !! (func:: Function , vi :: AbstractVarInfo )
261+ return setaccs!! (vi, map (func, getaccs (vi)))
262262end
263263
264264"""
265- map_accumulator!!(vi::AbstractVarInfo, ::Val{accname}, func::Function, args... ) where {accname}
265+ map_accumulator!!(func::Function, vi::AbstractVarInfo, ::Val{accname}) where {accname}
266266
267- Update the accumulator `accname` of `vi` by calling `func(acc, args...) ` on and replacing
268- it with the return value.
267+ Update the accumulator `accname` of `vi` by calling `func` on it and replacing it with the
268+ return value.
269269"""
270- function map_accumulator!! (vi :: AbstractVarInfo , accname :: Val , func :: Function , args ... )
271- return setaccs!! (vi, map_accumulator!! ( getaccs (vi), accname, func, args ... ))
270+ function map_accumulator!! (func :: Function , vi :: AbstractVarInfo , accname :: Val )
271+ return setaccs!! (vi, map_accumulator (func, getaccs (vi), accname))
272272end
273273
274- function map_accumulator!! (vi :: AbstractVarInfo , accname :: Symbol , func :: Function , args ... )
274+ function map_accumulator!! (func :: Function , vi :: AbstractVarInfo , accname :: Symbol )
275275 return error (
276276 """
277- The method
278- map_accumulator!!(vi::AbstractVarInfo, accname::Symbol, func::Function, args...)
277+ The method map_accumulator!!(func::Function, vi::AbstractVarInfo, accname::Symbol)
279278 does not exist. For type stability reasons use
280- map_accumulator!!(vi::AbstractVarInfo, accname::Val, func::Function, args...)
281- instead.
279+ map_accumulator!!(func::Function, vi::AbstractVarInfo, ::Val{accname}) instead.
282280 """
283281 )
284282end
@@ -291,7 +289,7 @@ Add `logp` to the value of the log of the prior probability in `vi`.
291289See also: [`accloglikelihood!!`](@ref), [`acclogp!!`](@ref), [`getlogprior`](@ref), [`setlogprior!!`](@ref).
292290"""
293291function acclogprior!! (vi:: AbstractVarInfo , logp)
294- return map_accumulator!! (vi, Val ( : LogPrior ), + , LogPrior (logp ))
292+ return map_accumulator!! (acc -> acc + LogPrior (logp ), vi, Val ( :LogPrior ))
295293end
296294
297295"""
@@ -302,7 +300,7 @@ Add `logp` to the value of the log of the likelihood in `vi`.
302300See also: [`accloglikelihood!!`](@ref), [`acclogp!!`](@ref), [`getloglikelihood`](@ref), [`setloglikelihood!!`](@ref).
303301"""
304302function accloglikelihood!! (vi:: AbstractVarInfo , logp)
305- return map_accumulator!! (vi, Val ( : LogLikelihood ), + , LogLikelihood (logp ))
303+ return map_accumulator!! (acc -> acc + LogLikelihood (logp ), vi, Val ( :LogLikelihood ))
306304end
307305
308306"""
@@ -326,10 +324,10 @@ Reset the values of the log probabilities (prior and likelihood) in `vi`
326324"""
327325function resetlogp!! (vi:: AbstractVarInfo )
328326 if hasacc (vi, Val (:LogPrior ))
329- vi = map_accumulator!! (vi, Val (:LogPrior ), zero )
327+ vi = map_accumulator!! (zero, vi, Val (:LogPrior ))
330328 end
331329 if hasacc (vi, Val (:LogLikelihood ))
332- vi = map_accumulator!! (vi, Val (:LogLikelihood ), zero )
330+ vi = map_accumulator!! (zero, vi, Val (:LogLikelihood ))
333331 end
334332 return vi
335333end
0 commit comments