@@ -24,11 +24,11 @@ model = (
2424m = Model (; zip (keys (model), values (model))... ) # uses Model(; kwargs...) constructor
2525
2626# test the type of the model is correct
27- @test typeof (m) <: Model
27+ @test m isa Model
2828sorted_vertices = get_sorted_vertices (m)
29- @test typeof (m) == Model{Tuple (sorted_vertices)}
30- @test typeof ( m. g) <: GraphInfo <: AbstractModelTrace
31- @test typeof ( m. g) == GraphInfo{Tuple (sorted_vertices)}
29+ @test m isa Model{Tuple (sorted_vertices)}
30+ @test m. g isa GraphInfo <: AbstractModelTrace
31+ @test m. g isa GraphInfo{Tuple (sorted_vertices)}
3232
3333# test the dag is correct
3434A = sparse ([0 0 0 0 0 ; 0 0 0 0 0 ; 0 0 0 0 0 ; 0 1 1 0 0 ; 1 0 0 1 0 ])
@@ -37,11 +37,18 @@ A = sparse([0 0 0 0 0; 0 0 0 0 0; 0 0 0 0 0; 0 1 1 0 0; 1 0 0 1 0])
3737@test length (m) == 5
3838@test eltype (m) == valtype (m)
3939
40+
4041# check the values from the NamedTuple match the values in the fields of GraphInfo
4142vals, evals, kinds = AbstractPPL. GraphPPL. getvals (NamedTuple {Tuple(sorted_vertices)} (model))
4243inputs = (s2 = (), xmat = (), β = (), μ = (:xmat , :β ), y = (:μ , :s2 ))
4344
4445for (i, vn) in enumerate (keys (m))
46+ @inferred m[vn]
47+ @inferred get_node_value (m, vn)
48+ @inferred get_node_eval (m, vn)
49+ @inferred get_nodekind (m, vn)
50+ @inferred get_node_input (m, vn)
51+
4552 @test vn isa VarName
4653 @test get_node_value (m, vn) == vals[i]
4754 @test get_node_eval (m, vn) == evals[i]
@@ -50,16 +57,16 @@ for (i, vn) in enumerate(keys(m))
5057end
5158
5259for node in m
53- @test typeof ( node) <: NamedTuple{fieldnames(GraphInfo)[1:4]}
60+ @test node isa NamedTuple{fieldnames (GraphInfo)[1 : 4 ]}
5461end
5562
5663# test Model constructor for model with single parent node
5764single_parent_m = Model (μ = (1.0 , () -> 3 , :Logical ), y = (1.0 , (μ) -> MvNormal (μ, sqrt (1 )), :Stochastic ))
58- @test typeof ( single_parent_m) == Model{(:μ , :y )}
59- @test typeof ( single_parent_m. g) == GraphInfo{(:μ , :y )}
65+ @test single_parent_m isa Model{(:μ , :y )}
66+ @test single_parent_m. g isa GraphInfo{(:μ , :y )}
6067
61- # test setindex
6268
69+ # test setindex
6370@test_throws AssertionError set_node_value! (m, @varname (s2), [0.0 ])
6471@test_throws AssertionError set_node_value! (m, @varname (s2), (1.0 ,))
6572set_node_value! (m, @varname (s2), 1.0 )
0 commit comments