Skip to content

Commit 30333d7

Browse files
committed
Fix prefixing test and docs
1 parent c699b8c commit 30333d7

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

docs/src/api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ even though [`Prior()`](@ref) is actually defined in the `Turing.Inference` modu
4040
| `@model` | [`DynamicPPL.@model`](@extref) | Define a probabilistic model |
4141
| `@varname` | [`AbstractPPL.@varname`](@extref) | Generate a `VarName` from a Julia expression |
4242
| `to_submodel` | [`DynamicPPL.to_submodel`](@extref) | Define a submodel |
43-
| `prefix` | [`DynamicPPL.prefix`](@extref) | Prefix all variable names in a model with a given symbol |
43+
| `prefix` | [`DynamicPPL.prefix`](@extref) | Prefix all variable names in a model with a given VarName |
4444
| `LogDensityFunction` | [`DynamicPPL.LogDensityFunction`](@extref) | A struct containing all information about how to evaluate a model. Mostly for advanced users |
4545

4646
### Inference

test/optimisation/Optimisation.jl

+3-7
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,9 @@ using Turing
7171
end
7272

7373
@testset "With prefixes" begin
74-
function prefix_μ(model)
75-
return DynamicPPL.contextualize(
76-
model, DynamicPPL.PrefixContext{:inner}(model.context)
77-
)
78-
end
79-
m1 = prefix_μ(model1(x))
80-
m2 = prefix_μ(model2() | (var"inner.x"=x,))
74+
vn = @varname(inner)
75+
m1 = prefix(model1(x), vn)
76+
m2 = prefix((model2() | (x=x,)), vn)
8177
ctx = Turing.Optimisation.OptimizationContext(DynamicPPL.LikelihoodContext())
8278
@test Turing.Optimisation.OptimLogDensity(m1, ctx)(w) ==
8379
Turing.Optimisation.OptimLogDensity(m2, ctx)(w)

0 commit comments

Comments
 (0)