@@ -243,7 +243,7 @@ julia> model() ≠ 1.0
243
243
true
244
244
245
245
julia> # To condition the variable inside `demo_inner` we need to refer to it as `inner.m`.
246
- conditioned_model = model | (var" inner.m" = 1.0, );
246
+ conditioned_model = model | (@varname( inner.m) => 1.0, );
247
247
248
248
julia> conditioned_model()
249
249
1.0
@@ -255,15 +255,6 @@ julia> conditioned_model_fail()
255
255
ERROR: ArgumentError: `~` with a model on the right-hand side of an observe statement is not supported
256
256
[...]
257
257
```
258
-
259
- And similarly when using `Dict`:
260
-
261
- ```jldoctest condition
262
- julia> conditioned_model_dict = model | (@varname(var"inner.m") => 1.0);
263
-
264
- julia> conditioned_model_dict()
265
- 1.0
266
- ```
267
258
"""
268
259
function AbstractPPL. condition (model:: Model , values... )
269
260
# Positional arguments - need to handle cases carefully
@@ -583,7 +574,7 @@ julia> model = demo_outer();
583
574
julia> model() ≠ 1.0
584
575
true
585
576
586
- julia> fixed_model = fix(model, var" inner.m" = 1.0, );
577
+ julia> fixed_model = fix(model, (@varname( inner.m) => 1.0, ) );
587
578
588
579
julia> fixed_model()
589
580
1.0
@@ -599,24 +590,9 @@ julia> fixed_model()
599
590
2.0
600
591
```
601
592
602
- And similarly when using `Dict`:
603
-
604
- ```jldoctest fix
605
- julia> fixed_model_dict = fix(model, @varname(var"inner.m") => 1.0);
606
-
607
- julia> fixed_model_dict()
608
- 1.0
609
-
610
- julia> fixed_model_dict = fix(model, @varname(inner) => 2.0);
611
-
612
- julia> fixed_model_dict()
613
- 2.0
614
- ```
615
-
616
593
## Difference from `condition`
617
594
618
- A very similar functionality is also provided by [`condition`](@ref) which,
619
- not surprisingly, _conditions_ variables instead of fixing them. The only
595
+ A very similar functionality is also provided by [`condition`](@ref). The only
620
596
difference between fixing and conditioning is as follows:
621
597
- `condition`ed variables are considered to be observations, and are thus
622
598
included in the computation [`logjoint`](@ref) and [`loglikelihood`](@ref),
@@ -798,11 +774,11 @@ julia> fixed(cm)
798
774
julia> # Since we fixed on `m`, not `a.m` as it will appear after prefixed,
799
775
# `a.m` is treated as a random variable.
800
776
keys(VarInfo(cm))
801
- 1-element Vector{VarName{Symbol("a.m"), typeof(identity) }}:
777
+ 1-element Vector{VarName{:a, Accessors.PropertyLens{:m} }}:
802
778
a.m
803
779
804
780
julia> # If we instead fix on `a.m`, `m` in the model will be considered an observation.
805
- cm = fix(contextualize(m, PrefixContext{:a}(fix(var" a.m"= 1.0))), x=100.0);
781
+ cm = fix(contextualize(m, PrefixContext{:a}(fix(@varname( a.m) => 1.0, ))), x=100.0);
806
782
807
783
julia> fixed(cm).x
808
784
100.0
0 commit comments