File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -194,14 +194,14 @@ include("logdensityfunction.jl")
194194include (" model_utils.jl" )
195195include (" extract_priors.jl" )
196196include (" values_as_in_model.jl" )
197+ include (" experimental.jl" )
197198include (" chains.jl" )
198199include (" bijector.jl" )
199200
200201include (" debug_utils.jl" )
201202using . DebugUtils
202203include (" test_utils.jl" )
203204
204- include (" experimental.jl" )
205205include (" deprecated.jl" )
206206
207207if isdefined (Base. Experimental, :register_error_hint )
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ function ParamsWithStats(
109109 else
110110 (DynamicPPL. ValuesAsInModelAccumulator (include_colon_eq),)
111111 end
112- return _, varinfo = DynamicPPL. Experimental. fast_evaluate!! (
112+ _, varinfo = DynamicPPL. Experimental. fast_evaluate!! (
113113 ldf. model, ctx, AccumulatorTuple (accs)
114114 )
115115 params = DynamicPPL. getacc (varinfo, Val (:ValuesAsInModel )). values
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ using DynamicPPL
44using Distributions
55using Test
66
7- @testset " ParamsWithStats" begin
7+ @testset " ParamsWithStats, from VarInfo " begin
88 @model function f (z)
99 x ~ Normal ()
1010 y := x + 1
@@ -66,4 +66,31 @@ using Test
6666 end
6767end
6868
69+ @testset " ParamsWithStats from FastLDF" begin
70+ @testset " $(m. f) " for m in DynamicPPL. TestUtils. DEMO_MODELS
71+ unlinked_vi = VarInfo (m)
72+ @testset " $islinked " for islinked in (false , true )
73+ vi = if islinked
74+ DynamicPPL. link!! (unlinked_vi, m)
75+ else
76+ unlinked_vi
77+ end
78+ nt_ranges, dict_ranges = DynamicPPL. Experimental. get_ranges_and_linked (vi)
79+ params = map (identity, vi[:])
80+
81+ # Get the ParamsWithStats using FastLDF
82+ fldf = DynamicPPL. Experimental. FastLDF (m, getlogjoint, vi)
83+ ps = ParamsWithStats (params, fldf)
84+
85+ # Check that length of parameters is as expected
86+ @test length (ps. params) == length (keys (vi))
87+
88+ # Iterate over all variables to check that their values match
89+ for vn in keys (vi)
90+ @test ps. params[vn] == vi[vn]
91+ end
92+ end
93+ end
94+ end
95+
6996end # module
You can’t perform that action at this time.
0 commit comments