Skip to content

Commit 9df4914

Browse files
committed
disable fallback for returned and pointwise_logdensities
1 parent 052bc19 commit 9df4914

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

HISTORY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# DynamicPPL Changelog
22

3+
## 0.38.10
4+
5+
`returned(model, chain)` and `pointwise_logdensities(model, chain)` will now error if a value for a random variable cannot be found in the chain.
6+
(Previously, they would instead resample such variables, which could lead to silent mistakes.)
7+
8+
If you encounter this error and it is accompanied by a warning about `hasvalue` not being implemented, you should be able to fix this by [using FlexiChains instead of MCMCChains](https://github.com/penelopeysm/FlexiChains.jl).
9+
(Alternatively, implementations of `hasvalue` for unsupported distributions are more than welcome; these must be provided in the Distributions extension of AbstractPPL.jl.)
10+
311
## 0.38.9
412

513
Remove warning when using Enzyme as the AD backend.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DynamicPPL"
22
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
3-
version = "0.38.9"
3+
version = "0.38.10"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

ext/DynamicPPLMCMCChainsExt.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ function DynamicPPL.predict(
226226
)
227227
predictions = map(params_and_stats) do ps
228228
_, varinfo = DynamicPPL.init!!(
229-
rng, model, varinfo, DynamicPPL.InitFromParams(ps.params)
229+
rng,
230+
model,
231+
varinfo,
232+
DynamicPPL.InitFromParams(ps.params, DynamicPPL.InitFromPrior()),
230233
)
231234
DynamicPPL.ParamsWithStats(varinfo)
232235
end
@@ -316,11 +319,7 @@ function DynamicPPL.returned(model::DynamicPPL.Model, chain_full::MCMCChains.Cha
316319
params_with_stats = AbstractMCMC.to_samples(DynamicPPL.ParamsWithStats, chain)
317320
return map(params_with_stats) do ps
318321
first(
319-
DynamicPPL.init!!(
320-
model,
321-
varinfo,
322-
DynamicPPL.InitFromParams(ps.params, DynamicPPL.InitFromPrior()),
323-
),
322+
DynamicPPL.init!!(model, varinfo, DynamicPPL.InitFromParams(ps.params, nothing))
324323
)
325324
end
326325
end
@@ -426,9 +425,7 @@ function DynamicPPL.pointwise_logdensities(
426425
values_dict = chain_sample_to_varname_dict(parameter_only_chain, sample_idx, chain_idx)
427426
# Re-evaluate the model
428427
_, vi = DynamicPPL.init!!(
429-
model,
430-
vi,
431-
DynamicPPL.InitFromParams(values_dict, DynamicPPL.InitFromPrior()),
428+
model, vi, DynamicPPL.InitFromParams(values_dict, nothing)
432429
)
433430
DynamicPPL.getacc(vi, Val(accname)).logps
434431
end

0 commit comments

Comments
 (0)