@@ -537,36 +537,36 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
537
537
end
538
538
end
539
539
540
- @testset " PriorInit " begin
541
- test_generating_new_values (PriorInit ())
542
- test_replacing_values (PriorInit ())
543
- test_rng_respected (PriorInit ())
544
- test_link_status_respected (PriorInit ())
540
+ @testset " InitFromPrior " begin
541
+ test_generating_new_values (InitFromPrior ())
542
+ test_replacing_values (InitFromPrior ())
543
+ test_rng_respected (InitFromPrior ())
544
+ test_link_status_respected (InitFromPrior ())
545
545
546
546
@testset " check that values are within support" begin
547
547
# Not many other sensible checks we can do for priors.
548
548
@model just_unif () = x ~ Uniform (0.0 , 1e-7 )
549
549
for _ in 1 : 100
550
- _, vi = DynamicPPL. init!! (just_unif (), VarInfo (), PriorInit ())
550
+ _, vi = DynamicPPL. init!! (just_unif (), VarInfo (), InitFromPrior ())
551
551
@test vi[@varname (x)] isa Real
552
552
@test 0.0 <= vi[@varname (x)] <= 1e-7
553
553
end
554
554
end
555
555
end
556
556
557
- @testset " UniformInit " begin
558
- test_generating_new_values (UniformInit ())
559
- test_replacing_values (UniformInit ())
560
- test_rng_respected (UniformInit ())
561
- test_link_status_respected (UniformInit ())
557
+ @testset " InitFromUniform " begin
558
+ test_generating_new_values (InitFromUniform ())
559
+ test_replacing_values (InitFromUniform ())
560
+ test_rng_respected (InitFromUniform ())
561
+ test_link_status_respected (InitFromUniform ())
562
562
563
563
@testset " check that bounds are respected" begin
564
564
@testset " unconstrained" begin
565
565
umin, umax = - 1.0 , 1.0
566
566
@model just_norm () = x ~ Normal ()
567
567
for _ in 1 : 100
568
568
_, vi = DynamicPPL. init!! (
569
- just_norm (), VarInfo (), UniformInit (umin, umax)
569
+ just_norm (), VarInfo (), InitFromUniform (umin, umax)
570
570
)
571
571
@test vi[@varname (x)] isa Real
572
572
@test umin <= vi[@varname (x)] <= umax
@@ -579,7 +579,7 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
579
579
tmin, tmax = inv_bijector (umin), inv_bijector (umax)
580
580
for _ in 1 : 100
581
581
_, vi = DynamicPPL. init!! (
582
- just_beta (), VarInfo (), UniformInit (umin, umax)
582
+ just_beta (), VarInfo (), InitFromUniform (umin, umax)
583
583
)
584
584
@test vi[@varname (x)] isa Real
585
585
@test tmin <= vi[@varname (x)] <= tmax
@@ -588,9 +588,9 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
588
588
end
589
589
end
590
590
591
- @testset " ParamsInit " begin
592
- test_link_status_respected (ParamsInit ((; a= 1.0 )))
593
- test_link_status_respected (ParamsInit (Dict (@varname (a) => 1.0 )))
591
+ @testset " InitFromParams " begin
592
+ test_link_status_respected (InitFromParams ((; a= 1.0 )))
593
+ test_link_status_respected (InitFromParams (Dict (@varname (a) => 1.0 )))
594
594
595
595
@testset " given full set of parameters" begin
596
596
# test_init_model has x ~ Normal() and y ~ MvNormal(zeros(2), I)
@@ -600,13 +600,13 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
600
600
model = test_init_model ()
601
601
@testset " $vi_name " for (vi_name, empty_vi) in empty_varinfos
602
602
_, vi = DynamicPPL. init!! (
603
- model, deepcopy (empty_vi), ParamsInit (params_nt)
603
+ model, deepcopy (empty_vi), InitFromParams (params_nt)
604
604
)
605
605
@test vi[@varname (x)] == my_x
606
606
@test vi[@varname (y)] == my_y
607
607
logp_nt = getlogp (vi)
608
608
_, vi = DynamicPPL. init!! (
609
- model, deepcopy (empty_vi), ParamsInit (params_dict)
609
+ model, deepcopy (empty_vi), InitFromParams (params_dict)
610
610
)
611
611
@test vi[@varname (x)] == my_x
612
612
@test vi[@varname (y)] == my_y
@@ -621,12 +621,12 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
621
621
params_dict = Dict (@varname (x) => my_x)
622
622
model = test_init_model ()
623
623
@testset " $vi_name " for (vi_name, empty_vi) in empty_varinfos
624
- @testset " with PriorInit fallback" begin
624
+ @testset " with InitFromPrior fallback" begin
625
625
_, vi = DynamicPPL. init!! (
626
626
Xoshiro (468 ),
627
627
model,
628
628
deepcopy (empty_vi),
629
- ParamsInit (params_nt, PriorInit ()),
629
+ InitFromParams (params_nt, InitFromPrior ()),
630
630
)
631
631
@test vi[@varname (x)] == my_x
632
632
nt_y = vi[@varname (y)]
@@ -636,7 +636,7 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
636
636
Xoshiro (469 ),
637
637
model,
638
638
deepcopy (empty_vi),
639
- ParamsInit (params_dict, PriorInit ()),
639
+ InitFromParams (params_dict, InitFromPrior ()),
640
640
)
641
641
@test vi[@varname (x)] == my_x
642
642
dict_y = vi[@varname (y)]
@@ -649,10 +649,10 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
649
649
@testset " with no fallback" begin
650
650
# These just don't have an entry for `y`.
651
651
@test_throws ErrorException DynamicPPL. init!! (
652
- model, deepcopy (empty_vi), ParamsInit (params_nt, nothing )
652
+ model, deepcopy (empty_vi), InitFromParams (params_nt, nothing )
653
653
)
654
654
@test_throws ErrorException DynamicPPL. init!! (
655
- model, deepcopy (empty_vi), ParamsInit (params_dict, nothing )
655
+ model, deepcopy (empty_vi), InitFromParams (params_dict, nothing )
656
656
)
657
657
# We also explicitly test the case where `y = missing`.
658
658
params_nt_missing = (; x= my_x, y= missing )
@@ -662,12 +662,12 @@ Base.IteratorEltype(::Type{<:AbstractContext}) = Base.EltypeUnknown()
662
662
@test_throws ErrorException DynamicPPL. init!! (
663
663
model,
664
664
deepcopy (empty_vi),
665
- ParamsInit (params_nt_missing, nothing ),
665
+ InitFromParams (params_nt_missing, nothing ),
666
666
)
667
667
@test_throws ErrorException DynamicPPL. init!! (
668
668
model,
669
669
deepcopy (empty_vi),
670
- ParamsInit (params_dict_missing, nothing ),
670
+ InitFromParams (params_dict_missing, nothing ),
671
671
)
672
672
end
673
673
end
0 commit comments