Skip to content

Commit dda56ec

Browse files
committed
use determine_suitable_varinfo in LogDensityFunction when not constructed
1 parent d7d785a commit dda56ec

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/logdensityfunction.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,22 @@ end
6565

6666
function LogDensityFunction(
6767
model::Model,
68-
varinfo::AbstractVarInfo=VarInfo(model),
6968
context::Union{Nothing,AbstractContext}=nothing,
7069
)
70+
# Determine the suitable varinfo for the given model and context.
71+
varinfo = determine_suitable_varinfo(model, context === nothing ? leafcontext(model.context) : context)
7172
return LogDensityFunction(varinfo, model, context)
7273
end
7374

75+
function LogDensityFunction(
76+
model::Model,
77+
varinfo::AbstractVarInfo,
78+
context::Union{Nothing,AbstractContext}=nothing,
79+
)
80+
return LogDensityFunction(varinfo, model, context)
81+
end
82+
83+
7484
# If a `context` has been specified, we use that. Otherwise we just use the leaf context of `model`.
7585
function getcontext(f::LogDensityFunction)
7686
return f.context === nothing ? leafcontext(f.model.context) : f.context

0 commit comments

Comments
 (0)