Skip to content
Closed
4 changes: 1 addition & 3 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ variables.
"""
function generate_tilde(left, right)
@gensym tmpright
top = [:($tmpright = $right),
:($tmpright isa Union{$Distribution,AbstractVector{<:$Distribution}}
|| throw(ArgumentError($DISTMSG)))]
top = [:($tmpright = $right),]

if left isa Symbol || left isa Expr
@gensym out vn inds isassumption
Expand Down
6 changes: 3 additions & 3 deletions src/context_implementations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ end
function assume(
rng,
spl::Union{SampleFromPrior,SampleFromUniform},
dist::Distribution,
dist,
vn::VarName,
vi,
)
Expand All @@ -144,12 +144,12 @@ end

function observe(
spl::Union{SampleFromPrior, SampleFromUniform},
dist::Distribution,
dist,
value,
vi,
)
increment_num_produce!(vi)
return Distributions.loglikelihood(dist, value)
return sum(Distributions.logpdf(dist, value))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is left-over from some earlier experimentation I did. We should make loglikelihood a primitive, and then work from there I think.

end

# .~ functions
Expand Down
5 changes: 5 additions & 0 deletions src/varinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ function VarInfo(old_vi::TypedVarInfo, spl, x::AbstractVector)
VarInfo(md, Base.RefValue{eltype(x)}(getlogp(old_vi)), Ref(get_num_produce(old_vi)))
end

function VarInfo(old_vi::TypedVarInfo, spl, x::AbstractVector, lp::T) where {T}
md = newmetadata(old_vi.metadata, Val(getspace(spl)), x)
VarInfo(md, Base.RefValue{T}(lp), Ref(get_num_produce(old_vi)))
end

function VarInfo(
rng::Random.AbstractRNG,
model::Model,
Expand Down