You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: HISTORY.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,11 +31,11 @@ This version therefore excises the context argument, and instead uses `model.con
31
31
The upshot of this is that many functions that previously took a context argument now no longer do.
32
32
There were very few such functions where the context argument was actually used (most of them simply took `DefaultContext()` as the default value).
33
33
34
-
`evaluate!!(model, varinfo, ext_context)` is deprecated, and broadly speaking you should replace calls to that with `new_model = contextualize(model, ext_context); evaluate!!(new_model, varinfo)`.
34
+
`evaluate!!(model, varinfo, ext_context)` is removed, and broadly speaking you should replace calls to that with `new_model = contextualize(model, ext_context); evaluate!!(new_model, varinfo)`.
35
35
If the 'external context' `ext_context` is a parent context, then you should wrap `model.context` appropriately to ensure that its information content is not lost.
36
36
If, on the other hand, `ext_context` is a `DefaultContext`, then you can just drop the argument entirely.
37
37
38
-
To aid with this process, `contextualize` is now exported from DynamicPPL.
38
+
**To aid with this process, `contextualize` is now exported from DynamicPPL.**
39
39
40
40
The main situation where one _did_ want to specify an additional evaluation context was when that context was a `SamplingContext`.
41
41
Doing this would allow you to run the model and sample fresh values, instead of just using the values that existed in the VarInfo object.
@@ -54,9 +54,10 @@ However, here are the more user-facing ones:
54
54
55
55
And a couple of more internal changes:
56
56
57
-
-`evaluate!!`, `evaluate_threadsafe!!`, and `evaluate_threadunsafe!!` no longer accept context arguments
57
+
-Just like `evaluate!!`, the other functions `_evaluate!!`, `evaluate_threadsafe!!`, and `evaluate_threadunsafe!!` now no longer accept context arguments
58
58
-`evaluate!!` no longer takes rng and sampler (if you used this, you should use `evaluate_and_sample!!` instead, or construct your own `SamplingContext`)
59
59
- The model evaluation function, `model.f` for some `model::Model`, no longer takes a context as an argument
60
+
- The internal representation and API dealing with submodels (i.e., `ReturnedModelWrapper`, `Sampleable`, `should_auto_prefix`, `is_rhs_model`) has been simplified. If you need to check whether something is a submodel, just use `x isa DynamicPPL.Submodel`. Note that the public API i.e. `to_submodel` remains completely untouched.
Copy file name to clipboardExpand all lines: docs/src/api.md
-6Lines changed: 0 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,12 +152,6 @@ In the context of including models within models, it's also useful to prefix the
152
152
DynamicPPL.prefix
153
153
```
154
154
155
-
Under the hood, [`to_submodel`](@ref) makes use of the following method to indicate that the model it's wrapping is a model over its return-values rather than something else
156
-
157
-
```@docs
158
-
returned(::Model)
159
-
```
160
-
161
155
## Utilities
162
156
163
157
It is possible to manually increase (or decrease) the accumulated log likelihood or prior from within a model function.
Copy file name to clipboardExpand all lines: src/DynamicPPL.jl
+16-1Lines changed: 16 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -171,11 +171,11 @@ abstract type AbstractVarInfo <: AbstractModelTrace end
171
171
include("utils.jl")
172
172
include("chains.jl")
173
173
include("model.jl")
174
-
include("submodel.jl")
175
174
include("sampler.jl")
176
175
include("varname.jl")
177
176
include("distribution_wrappers.jl")
178
177
include("contexts.jl")
178
+
include("submodel.jl")
179
179
include("varnamedvector.jl")
180
180
include("accumulators.jl")
181
181
include("default_accumulators.jl")
@@ -226,6 +226,21 @@ if isdefined(Base.Experimental, :register_error_hint)
226
226
)
227
227
end
228
228
end
229
+
230
+
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, _
231
+
is_evaluate_three_arg =
232
+
exc.f === AbstractPPL.evaluate!! &&
233
+
length(argtypes) ==3&&
234
+
argtypes[1] <:Model&&
235
+
argtypes[2] <:AbstractVarInfo&&
236
+
argtypes[3] <:AbstractContext
237
+
if is_evaluate_three_arg
238
+
print(
239
+
io,
240
+
"\n\nThe method `evaluate!!(model, varinfo, new_ctx)` has been removed. Instead, you should store the `new_ctx` in the `model.context` field using `new_model = contextualize(model, new_ctx)`, and then call `evaluate!!(new_model, varinfo)` on the new model. (Note that, if the model already contained a non-default context, you will need to wrap the existing context.)",
0 commit comments