Skip to content

Commit 1267785

Browse files
committed
putting GraphInfo into submodule GraphPPL
1 parent ebcacae commit 1267785

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/AbstractPPL.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export VarName, getsym, getlens, inspace, subsumes, varname, vsym, @varname, @vs
77
# Abstract model functions
88
export AbstractProbabilisticProgram, condition, decondition, logdensityof, densityof
99

10-
# GraphInfo
11-
export GraphInfo, Model, dag, nodes
12-
1310
# Abstract traces
1411
export AbstractModelTrace
1512

@@ -18,5 +15,11 @@ include("varname.jl")
1815
include("abstractmodeltrace.jl")
1916
include("abstractprobprog.jl")
2017
include("deprecations.jl")
21-
include("graphinfo.jl")
18+
19+
# GraphInfo
20+
module GraphPPL
21+
include("graphinfo.jl")
22+
export GraphInfo, Model, dag, nodes
23+
end
24+
2225
end # module

test/graphinfo.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using AbstractPPL
1+
using AbstractPPL.GraphPPL
22
using SparseArrays
33

44
## Example taken from Mamba
@@ -19,9 +19,10 @@ model = (
1919

2020
# construct the model!
2121
m = Model(; zip(keys(model), values(model))...) # uses Model(; kwargs...) constructor
22-
22+
typeof(m)
2323
# test the type of the model is correct
24-
@test typeof(m) == Model
24+
@test typeof(m) <: Model
25+
@test typeof(m) == Model{(:s2, :xmat, , , :y)}
2526
@test typeof(m.g) <: GraphInfo <: AbstractModelTrace
2627
@test typeof(m.g) == GraphInfo{(:s2, :xmat, , , :y)}
2728

@@ -33,7 +34,7 @@ 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])
3334
@test eltype(m) == valtype(m)
3435

3536
# check the values from the NamedTuple match the values in the fields of GraphInfo
36-
vals = AbstractPPL.getvals(model)
37+
vals = AbstractPPL.GraphPPL.getvals(model)
3738
for (i, field) in enumerate([:value, :eval, :kind])
3839
@test eval( :( values(m.g.$field) == vals[$i] ) )
3940
end
@@ -52,7 +53,7 @@ end
5253

5354
# test Model constructor for model with single parent node
5455
single_parent_m = Model= (1.0, () -> 3, :Logical), y = (1.0, (μ) -> MvNormal(μ, sqrt(1)), :Stochastic))
55-
@test typeof(single_parent_m) == Model
56+
@test typeof(single_parent_m) == Model{(, :y)}
5657
@test typeof(single_parent_m.g) == GraphInfo{(, :y)}
5758

5859
# test ErrorException for parent node not found

0 commit comments

Comments
 (0)