Skip to content

Commit fdbf540

Browse files
authored
Merge pull request #498 from JuliaRobotics/testing/2Q20/loadassert
assert loadDFG, listSupersolve
2 parents 5eef136 + 9f1f9b0 commit fdbf540

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export exists,
6868
updateVariable!, updateFactor!,
6969
deleteVariable!, deleteFactor!,
7070
listVariables, listFactors,
71+
listSolvekeys, listSupersolves,
7172
getVariables, getFactors,
7273
isVariable, isFactor
7374

src/services/AbstractDFG.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,24 @@ function listFactors(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; tags::V
493493
return map(f -> f.label, getFactors(dfg, regexFilter, tags=tags, solvable=solvable))
494494
end
495495

496+
"""
497+
$SIGNATURES
498+
List all the solvekeys used amongst all variables in the distributed factor graph object.
499+
500+
Related
501+
502+
listSupersolves, getSolverDataDict, listVariables
503+
"""
504+
function listSolvekeys(dfg::AbstractDFG)
505+
skeys = Set{Symbol}()
506+
for vs in listVariables(dfg), ky in keys(getSolverDataDict(getVariable(dfg, vs)))
507+
push!(skeys, ky)
508+
end
509+
return skeys
510+
end
511+
const listSupersolves = listSolvekeys
512+
513+
496514
##------------------------------------------------------------------------------
497515
## Aliases and Other filtered lists
498516
##------------------------------------------------------------------------------

test/fileDFGTests.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ using Test
4545
saveDFG(dfg, filename)
4646

4747
copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
48+
copyDf2 = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
4849
@info "Going to load $filename"
4950

50-
#FIXME loadDFG!(copyDfg, filename), but use this to test deprecation
51-
retDFG = loadDFG(filename, Main, copyDfg) #, loaddir="/tmp")
51+
@test_throws AssertionError loadDFG!(copyDf2,"badfilename")
52+
53+
retDFG = loadDFG!(copyDfg, filename)
54+
# TODO REMOVE test deprecation
55+
retDFG_ = loadDFG(filename, Main, copyDfg2) #, loaddir="/tmp")
5256

5357
@test issetequal(ls(dfg), ls(retDFG))
5458
@test issetequal(lsf(dfg), lsf(retDFG))

test/testBlocks.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,11 @@ end
507507
@test ls(fg) == listVariables(fg)
508508
@test lsf(fg) == listFactors(fg)
509509

510+
if getVariable(fg, ls(fg)[1]) isa DFGVariable
511+
@test :default in listSolvekeys(fg)
512+
@test :default in listSupersolves(fg)
513+
end
514+
510515
# simple broadcast test
511516
if f0 isa DFGFactor
512517
@test issetequal(getFactorType.(fg, lsf(fg)), [TestFunctorInferenceType1(), TestFunctorSingleton()])

0 commit comments

Comments
 (0)