Skip to content

Commit 60df8d5

Browse files
committed
imprv tests
1 parent 78fc6dc commit 60df8d5

File tree

1 file changed

+56
-28
lines changed

1 file changed

+56
-28
lines changed

test/testBlocks.jl

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,36 +1598,35 @@ function FileDFGTestBlock(testDFGAPI; kwargs...)
15981598
# kwargs = ()
15991599
# filename = "/tmp/fileDFG"
16001600
dfg, verts, facs = connectivityTestGraph(testDFGAPI; kwargs...)
1601+
v4 = getVariable(dfg, :x4)
1602+
vnd = getState(v4, :default)
1603+
# set everything
1604+
# vnd.BayesNetVertID = :outid
1605+
# push!(vnd.BayesNetOutVertIDs, :id)
1606+
# vnd.bw[1] = [1.0;]
1607+
# vnd.dontmargin = true
1608+
# vnd.eliminated = true
1609+
vnd.observability .= Float64[1.5;]
1610+
vnd.initialized = true
1611+
vnd.marginalized = true
1612+
push!(vnd.separator, :sep)
1613+
vnd.solves = 2
1614+
# vnd.val[1] = [2.0;]
1615+
#update
1616+
mergeVariable!(dfg, v4)
1617+
1618+
f45 = getFactor(dfg, :x4x5f1)
1619+
fsd = getFactorState(f45)
1620+
# set some factor solver data
1621+
push!(fsd.certainhypo, 2)
1622+
fsd.eliminated = true
1623+
push!(fsd.multihypo, 4.0)
1624+
fsd.nullhypo = 5.0
1625+
fsd.potentialused = true
1626+
#update factor
1627+
mergeFactor!(dfg, f45)
16011628

16021629
for filename in ["/tmp/fileDFG", "/tmp/FileDFGExtension.tar.gz"]
1603-
v4 = getVariable(dfg, :x4)
1604-
vnd = getState(v4, :default)
1605-
# set everything
1606-
# vnd.BayesNetVertID = :outid
1607-
# push!(vnd.BayesNetOutVertIDs, :id)
1608-
# vnd.bw[1] = [1.0;]
1609-
# vnd.dontmargin = true
1610-
# vnd.eliminated = true
1611-
vnd.observability .= Float64[1.5;]
1612-
vnd.initialized = true
1613-
vnd.marginalized = true
1614-
push!(vnd.separator, :sep)
1615-
vnd.solves = 2
1616-
# vnd.val[1] = [2.0;]
1617-
#update
1618-
mergeVariable!(dfg, v4)
1619-
1620-
f45 = getFactor(dfg, :x4x5f1)
1621-
fsd = getFactorState(f45)
1622-
# set some factor solver data
1623-
push!(fsd.certainhypo, 2)
1624-
fsd.eliminated = true
1625-
push!(fsd.multihypo, 4.0)
1626-
fsd.nullhypo = 5.0
1627-
fsd.potentialused = true
1628-
#update factor
1629-
mergeFactor!(dfg, f45)
1630-
16311630
# Save and load the graph to test.
16321631
saveDFG(dfg, filename)
16331632

@@ -1647,9 +1646,38 @@ function FileDFGTestBlock(testDFGAPI; kwargs...)
16471646
@test getFactor(dfg, fact) == getFactor(retDFG, fact)
16481647
end
16491648

1649+
dfg2 = loadDFG(filename)
1650+
1651+
@test issetequal(ls(dfg), ls(dfg2))
1652+
@test issetequal(lsf(dfg), lsf(dfg2))
1653+
for var in ls(dfg)
1654+
@test getVariable(dfg, var) == getVariable(dfg2, var)
1655+
end
1656+
for fact in lsf(dfg)
1657+
@test getFactor(dfg, fact) == getFactor(dfg2, fact)
1658+
end
1659+
#TODO test graph, agent, blob stores, solverdata.
1660+
16501661
# @test length(getBlobentries(getVariable(retDFG, :x1))) == 1
16511662
# @test typeof(getBlobentry(getVariable(retDFG, :x1),:testing)) == GeneralDataEntry
16521663
# @test length(getBlobentries(getVariable(retDFG, :x2))) == 1
16531664
# @test typeof(getBlobentry(getVariable(retDFG, :x2),:testing2)) == FileDataEntry
16541665
end
1666+
1667+
filename = "/tmp/fileDFG"
1668+
summarydfg = testDFGAPI{NoSolverParams, VariableSummary, FactorSummary}(;
1669+
graphLabel = :testGraph,
1670+
)
1671+
loadDFG!(summarydfg, filename)
1672+
1673+
@test issetequal(ls(dfg), ls(summarydfg))
1674+
@test issetequal(lsf(dfg), lsf(summarydfg))
1675+
1676+
skeletondfg = testDFGAPI{NoSolverParams, VariableSkeleton, FactorSkeleton}(;
1677+
graphLabel = :testGraph,
1678+
)
1679+
loadDFG!(skeletondfg, filename)
1680+
1681+
@test issetequal(ls(dfg), ls(skeletondfg))
1682+
@test issetequal(lsf(dfg), lsf(skeletondfg))
16551683
end

0 commit comments

Comments
 (0)