@@ -24,11 +24,11 @@ model = (
24
24
m = Model (; zip (keys (model), values (model))... ) # uses Model(; kwargs...) constructor
25
25
26
26
# test the type of the model is correct
27
- @test typeof (m) <: Model
27
+ @test m isa Model
28
28
sorted_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)}
32
32
33
33
# test the dag is correct
34
34
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 ])
@@ -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])
37
37
@test length (m) == 5
38
38
@test eltype (m) == valtype (m)
39
39
40
+
40
41
# check the values from the NamedTuple match the values in the fields of GraphInfo
41
42
vals, evals, kinds = AbstractPPL. GraphPPL. getvals (NamedTuple {Tuple(sorted_vertices)} (model))
42
43
inputs = (s2 = (), xmat = (), β = (), μ = (:xmat , :β ), y = (:μ , :s2 ))
43
44
44
45
for (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
+
45
52
@test vn isa VarName
46
53
@test get_node_value (m, vn) == vals[i]
47
54
@test get_node_eval (m, vn) == evals[i]
@@ -50,16 +57,16 @@ for (i, vn) in enumerate(keys(m))
50
57
end
51
58
52
59
for node in m
53
- @test typeof ( node) <: NamedTuple{fieldnames(GraphInfo)[1:4]}
60
+ @test node isa NamedTuple{fieldnames (GraphInfo)[1 : 4 ]}
54
61
end
55
62
56
63
# test Model constructor for model with single parent node
57
64
single_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 )}
60
67
61
- # test setindex
62
68
69
+ # test setindex
63
70
@test_throws AssertionError set_node_value! (m, @varname (s2), [0.0 ])
64
71
@test_throws AssertionError set_node_value! (m, @varname (s2), (1.0 ,))
65
72
set_node_value! (m, @varname (s2), 1.0 )
0 commit comments