Skip to content

Commit fec95c2

Browse files
rikhuijzerRik Huijzer
andcommitted
Fix conditioned doctest for Julia 1.8-beta1 (#388)
The tests were failing on a changed display for var objects: ``` │ Subexpression: │ │ conditioned(cm) │ │ Evaluated output: │ │ (x = 100.0, var"a.m" = 1.0) │ │ Expected output: │ │ (x = 100.0, a.m = 1.0) │ │ diff = │ Warning: Diff output requires color. │ (x = 100.0, a.m var"a.m" = 1.0) ``` This is why the the nanosoldier runs show that DynamicPPL fails on Julia 1.8-beta1 (https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/fb69baf_vs_40279f9/report.html). I've tried to come up with a doctestfilter, but don't think that's possible in this case. Therefore, I suggest that we only run the tests on the latest stable release. This solves two problems: - Nightly/beta/release-candidate releases failing due to changes in how output appears - Simplify code; especially avoids that a doctestfilter allows some test to pass where it should fail I've tested this PR on Julia 1.8.0-beta1 locally. All tests passed. Co-authored-by: Rik Huijzer <[email protected]>
1 parent c655d8c commit fec95c2

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

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.17.8"
3+
version = "0.17.9"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

docs/make.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ makedocs(;
1111
pages=["Home" => "index.md", "TestUtils" => "test_utils.md"],
1212
strict=true,
1313
checkdocs=:exports,
14-
doctestfilters=[
15-
# Older versions will show "0 element Array" instead of "Type[]".
16-
r"(Any\[\]|0-element Array{.+,[0-9]+})",
17-
# Older versions will show "Array{...,1}" instead of "Vector{...}".
18-
r"(Array{.+,\s?1}|Vector{.+})",
19-
# Older versions will show "Array{...,2}" instead of "Matrix{...}".
20-
r"(Array{.+,\s?2}|Matrix{.+})",
21-
# Errors from macros sometimes result in `LoadError: LoadError:`
22-
# rather than `LoadError:`, depending on Julia version.
23-
r"ERROR: (LoadError:\s)+",
24-
],
2514
)
2615

2716
deploydocs(; repo="github.com/TuringLang/DynamicPPL.jl.git", push_preview=true)

src/model.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ in their trace/`VarInfo`:
242242
243243
```jldoctest condition
244244
julia> keys(VarInfo(demo_outer()))
245-
1-element Vector{VarName{:m, Tuple{}}}:
245+
1-element Vector{VarName{:m, Setfield.IdentityLens}}:
246246
m
247247
248248
julia> keys(VarInfo(demo_outer_prefix()))
249-
1-element Vector{VarName{Symbol("inner.m"), Tuple{}}}:
249+
1-element Vector{VarName{Symbol("inner.m"), Setfield.IdentityLens}}:
250250
inner.m
251251
```
252252
@@ -350,14 +350,17 @@ julia> conditioned(cm)
350350
julia> # Since we conditioned on `m`, not `a.m` as it will appear after prefixed,
351351
# `a.m` is treated as a random variable.
352352
keys(VarInfo(cm))
353-
1-element Vector{VarName{Symbol("a.m"), Tuple{}}}:
353+
1-element Vector{VarName{Symbol("a.m"), Setfield.IdentityLens}}:
354354
a.m
355355
356356
julia> # If we instead condition on `a.m`, `m` in the model will be considered an observation.
357357
cm = condition(contextualize(m, PrefixContext{:a}(condition(var"a.m"=1.0))), x=100.0);
358358
359-
julia> conditioned(cm)
360-
(x = 100.0, a.m = 1.0)
359+
julia> conditioned(cm).x
360+
100.0
361+
362+
julia> conditioned(cm).var"a.m"
363+
1.0
361364
362365
julia> keys(VarInfo(cm)) # <= no variables are sampled
363366
Any[]

0 commit comments

Comments
 (0)