Skip to content

Commit 993cc5b

Browse files
committed
Merge remote-tracking branch 'origin/main' into breaking
2 parents c27f5e0 + 6c615ad commit 993cc5b

File tree

11 files changed

+80
-24
lines changed

11 files changed

+80
-24
lines changed

.github/workflows/Benchmarking.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
results: ${{ steps.benchmark.outputs.results }}
1111
sha: ${{ steps.benchmark.outputs.sha }}
1212
steps:
13-
- uses: actions/checkout@v5
13+
- uses: actions/checkout@v6
1414
with:
1515
ref: ${{ github.base_ref }}
1616
- uses: julia-actions/setup-julia@v2
@@ -35,7 +35,7 @@ jobs:
3535
results: ${{ steps.benchmark.outputs.results }}
3636
sha: ${{ steps.benchmark.outputs.sha }}
3737
steps:
38-
- uses: actions/checkout@v5
38+
- uses: actions/checkout@v6
3939
with:
4040
ref: ${{ github.event.pull_request.head.sha }}
4141
- uses: julia-actions/setup-julia@v2
@@ -58,7 +58,7 @@ jobs:
5858
runs-on: ubuntu-latest
5959
needs: [benchmark-base, benchmark-head]
6060
steps:
61-
- uses: actions/checkout@v5
61+
- uses: actions/checkout@v6
6262
with:
6363
ref: ${{ github.event.pull_request.head.sha }}
6464
- uses: julia-actions/setup-julia@v2

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- Group2
5757

5858
steps:
59-
- uses: actions/checkout@v5
59+
- uses: actions/checkout@v6
6060

6161
- uses: julia-actions/setup-julia@v2
6262
with:

.github/workflows/DocTest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727

2828
steps:
29-
- uses: actions/checkout@v5
29+
- uses: actions/checkout@v6
3030

3131
- uses: julia-actions/setup-julia@v2
3232
with:

.github/workflows/DocsNav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout gh-pages branch
20-
uses: actions/checkout@v5
20+
uses: actions/checkout@v6
2121
with:
2222
ref: gh-pages
2323

.github/workflows/DocsPreviewCleanup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout gh-pages branch
12-
uses: actions/checkout@v5
12+
uses: actions/checkout@v6
1313
with:
1414
ref: gh-pages
1515
- name: Delete preview and history + push changes

.github/workflows/Enzyme.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
enzyme:
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424

2525
- uses: julia-actions/setup-julia@v2
2626
with:

.github/workflows/IntegrationTest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- {user: TuringLang, repo: Turing.jl}
2222

2323
steps:
24-
- uses: actions/checkout@v5
24+
- uses: actions/checkout@v6
2525

2626
- uses: julia-actions/setup-julia@v2
2727
with:
@@ -30,7 +30,7 @@ jobs:
3030
- uses: julia-actions/julia-buildpkg@v1
3131

3232
- name: Clone Downstream
33-
uses: actions/checkout@v5
33+
uses: actions/checkout@v6
3434
with:
3535
repository: ${{ matrix.package.user }}/${{ matrix.package.repo }}
3636
path: downstream

.github/workflows/JuliaPre.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- Group2
2525

2626
steps:
27-
- uses: actions/checkout@v5
27+
- uses: actions/checkout@v6
2828
- uses: julia-actions/setup-julia@v2
2929
with:
3030
version: 'pre' # pre-release

HISTORY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ This is a generalisation of the previous behaviour, where `init` would always re
7777
The family of functions `returned(model, chain)`, along with the same signatures of `pointwise_logdensities`, `logjoint`, `loglikelihood`, and `logprior`, have been changed such that if the chain does not contain all variables in the model, an error is thrown.
7878
Previously the behaviour would have been to sample missing variables.
7979

80+
## 0.38.10
81+
82+
`returned(model, chain)` and `pointwise_logdensities(model, chain)` will now error if a value for a random variable cannot be found in the chain.
83+
(Previously, they would instead resample such variables, which could lead to silent mistakes.)
84+
85+
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).
86+
(Alternatively, implementations of `hasvalue` for unsupported distributions are more than welcome; these must be provided in the Distributions extension of AbstractPPL.jl.)
87+
8088
## 0.38.9
8189

8290
Remove warning when using Enzyme as the AD backend.

test/ext/DynamicPPLMCMCChainsExt.jl

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ module DynamicPPLMCMCChainsExtTests
33
using DynamicPPL, Distributions, MCMCChains, Test, AbstractMCMC
44

55
@testset "DynamicPPLMCMCChainsExt" begin
6-
@model demo() = x ~ Normal()
7-
model = demo()
8-
9-
chain = MCMCChains.Chains(
10-
randn(1000, 2, 1),
11-
[:x, :y],
12-
Dict(:internals => [:y]);
13-
info=(; varname_to_symbol=Dict(@varname(x) => :x)),
14-
)
15-
chain_generated = @test_nowarn returned(model, chain)
16-
@test size(chain_generated) == (1000, 1)
17-
@test mean(chain_generated) 0 atol = 0.1
18-
196
@testset "from_samples" begin
207
@model function f(z)
218
x ~ Normal()
@@ -61,6 +48,42 @@ using DynamicPPL, Distributions, MCMCChains, Test, AbstractMCMC
6148
@test new_p.stats == p.stats
6249
end
6350
end
51+
52+
@testset "returned (basic)" begin
53+
@model demo() = x ~ Normal()
54+
model = demo()
55+
56+
chain = MCMCChains.Chains(
57+
randn(1000, 2, 1),
58+
[:x, :y],
59+
Dict(:internals => [:y]);
60+
info=(; varname_to_symbol=Dict(@varname(x) => :x)),
61+
)
62+
chain_generated = @test_nowarn returned(model, chain)
63+
@test size(chain_generated) == (1000, 1)
64+
@test mean(chain_generated) 0 atol = 0.1
65+
end
66+
67+
@testset "returned: errors on missing variable" begin
68+
# Create a chain that only has `m`.
69+
@model function m_only()
70+
return m ~ Normal()
71+
end
72+
model_m_only = m_only()
73+
chain_m_only = AbstractMCMC.from_samples(
74+
MCMCChains.Chains,
75+
hcat([ParamsWithStats(VarInfo(model_m_only), model_m_only) for _ in 1:50]),
76+
)
77+
78+
# Define a model that needs both `m` and `s`.
79+
@model function f()
80+
m ~ Normal()
81+
s ~ Exponential()
82+
return y ~ Normal(m, s)
83+
end
84+
model = f() | (; y=1.0)
85+
@test_throws "No value was provided" returned(model, chain_m_only)
86+
end
6487
end
6588

6689
# test for `predict` is in `test/model.jl`

0 commit comments

Comments
 (0)