@@ -794,22 +794,23 @@ julia> # Now `a.x` will be sampled.
794
794
fixed (model:: Model ) = fixed (model. context)
795
795
796
796
"""
797
- (model::Model)([rng[ , varinfo] ])
797
+ (model::Model)([rng, varinfo])
798
798
799
- Sample from the `model` using the `sampler` with random number generator `rng`
800
- and the `context`, and store the sample and log joint probability in `varinfo`.
799
+ Sample from the prior of the `model` with random number generator `rng`.
801
800
802
801
Returns the model's return value.
803
802
804
- If no arguments are provided, uses the default random number generator and
805
- samples from the prior.
803
+ Note that calling this with an existing `varinfo` object will mutate it.
806
804
"""
805
+ (model:: Model )() = model (Random. default_rng (), VarInfo ())
806
+ function (model:: Model )(varinfo:: AbstractVarInfo )
807
+ return model (Random. default_rng (), varinfo)
808
+ end
809
+ # ^ Weird Documenter.jl bug means that we have to write the two above separately
810
+ # as it can only detect the `function`-less syntax.
807
811
function (model:: Model )(rng:: Random.AbstractRNG , varinfo:: AbstractVarInfo = VarInfo ())
808
812
return first (sample!! (rng, model, varinfo))
809
813
end
810
- function (model:: Model )(varinfo:: AbstractVarInfo = VarInfo ())
811
- return model (Random. default_rng (), varinfo)
812
- end
813
814
814
815
"""
815
816
use_threadsafe_eval(context::AbstractContext, varinfo::AbstractVarInfo)
@@ -853,10 +854,10 @@ end
853
854
854
855
Evaluate the `model` with the given `varinfo`. If an extra context stack is
855
856
provided, the model's context is inserted into that context stack. See
856
- [ `combine_model_and_external_contexts`](@ref) .
857
+ `combine_model_and_external_contexts`.
857
858
858
859
If multiple threads are available, the varinfo provided will be wrapped in a
859
- [`DynamicPPL. ThreadSafeVarInfo`](@ref) before evaluation.
860
+ ` ThreadSafeVarInfo` before evaluation.
860
861
861
862
Returns a tuple of the model's return value, plus the updated `varinfo`
862
863
(unwrapped if necessary).
871
872
function AbstractPPL. evaluate!! (
872
873
model:: Model , varinfo:: AbstractVarInfo , context:: AbstractContext
873
874
)
875
+ Base. depwarn (
876
+ " The `context` argument to evaluate!!(model, varinfo, context) is deprecated." ,
877
+ :dynamicppl_evaluate_context ,
878
+ )
874
879
new_ctx = combine_model_and_external_contexts (model. context, context)
875
880
model = contextualize (model, new_ctx)
876
881
return evaluate!! (model, varinfo)
0 commit comments