Skip to content

Commit ebcacae

Browse files
committed
adding type annotations for Model; adding tests for Model iterator type
1 parent 0ce30f1 commit ebcacae

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/graphinfo.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ y = (value = 0.0, input = (:μ, :s2), eval = var"#7#10"(), kind = :Stochastic)
5555
```
5656
"""
5757

58-
struct Model
59-
g::GraphInfo
58+
struct Model{T}
59+
g::GraphInfo{T}
6060
end
6161

6262
function Model(;kwargs...)

test/graphinfo.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ 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])
3535
# check the values from the NamedTuple match the values in the fields of GraphInfo
3636
vals = AbstractPPL.getvals(model)
3737
for (i, field) in enumerate([:value, :eval, :kind])
38-
@test eval( :(values(m.g.$field) == vals[$i]) )
38+
@test eval( :( values(m.g.$field) == vals[$i] ) )
39+
end
40+
41+
for node in m
42+
@test typeof(node) <: NamedTuple{fieldnames(GraphInfo)[1:4]}
3943
end
4044

4145
# test the right inputs have been inferred
@@ -46,7 +50,6 @@ for key in keys(m)
4650
@test typeof(key) <: VarName
4751
end
4852

49-
5053
# test Model constructor for model with single parent node
5154
single_parent_m = Model= (1.0, () -> 3, :Logical), y = (1.0, (μ) -> MvNormal(μ, sqrt(1)), :Stochastic))
5255
@test typeof(single_parent_m) == Model

0 commit comments

Comments
 (0)