Skip to content

Commit b110db9

Browse files
committed
Working on tests
1 parent 82cc26f commit b110db9

File tree

4 files changed

+105
-104
lines changed

4 files changed

+105
-104
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ function isFullyConnected(dfg::CloudGraphsDFG)::Bool
636636

637637
# Total connected nodes - thank you Neo4j for 0..* awesomeness!!
638638
query = """
639-
match (n:testUser:testRobot:sandbox:a)-[FACTORGRAPH*]-(node:testUser:testRobot:sandbox)
639+
match (n:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId):$(varIds[1]))-[FACTORGRAPH*]-(node:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId))
640640
WHERE n:VARIABLE OR n:FACTOR OR node:VARIABLE OR node:FACTOR
641641
WITH collect(n)+collect(node) as nodelist
642642
unwind nodelist as nodes

src/services/AbstractDFG.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ showFactor(fgl::G, fsym::Symbol) where G <: AbstractDFG = @show getFactor(fgl,fs
523523
Produces a dot-format of the graph for visualization.
524524
"""
525525
function toDot(dfg::AbstractDFG)::String
526-
@warn "Falling Back to convert to GraphsDFG"
527526
#TODO implement convert
528527
graphsdfg = GraphsDFG{AbstractParams}()
529528
DistributedFactorGraphs._copyIntoGraph!(dfg, graphsdfg, union(getVariableIds(dfg), getFactorIds(dfg)), true)

test/iifInterfaceTests.jl

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
global dfg,v1,v2,f1
22

33
if typeof(dfg) <: CloudGraphsDFG
4-
@warn "TEST: Nuking all data for robot $(dfg.robotId)!"
4+
@warn "TEST: Nuking all data for user '$(dfg.userId)', robot '$(dfg.robotId)'!"
55
clearRobot!!(dfg)
66
end
77

@@ -248,104 +248,104 @@ end
248248
end
249249

250250

251-
# Now make a complex graph for connectivity tests
252-
numNodes = 10
253-
#the deletions in last test should have cleared out the fg
254-
# dfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
255-
# if typeof(dfg) <: CloudGraphsDFG
256-
# clearSession!!(dfg)
251+
# # Now make a complex graph for connectivity tests
252+
# numNodes = 10
253+
# #the deletions in last test should have cleared out the fg
254+
# # dfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
255+
# # if typeof(dfg) <: CloudGraphsDFG
256+
# # clearSession!!(dfg)
257+
# # end
258+
#
259+
# #change ready and backendset for x7,x8 for improved tests on x7x8f1
260+
# verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes)
261+
# #TODO fix this to use accessors
262+
# verts[7].ready = 1
263+
# # verts[7].backendset = 0
264+
# verts[8].ready = 0
265+
# verts[8].backendset = 1
266+
# #call update to set it on cloud
267+
# updateVariable!(dfg, verts[7])
268+
# updateVariable!(dfg, verts[8])
269+
#
270+
# facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1))
271+
#
272+
# @testset "Getting Neighbors" begin
273+
# global dfg,verts
274+
# # Trivial test to validate that intersect([], []) returns order of first parameter
275+
# @test intersect([:x3, :x2, :x1], [:x1, :x2]) == [:x2, :x1]
276+
# # Get neighbors tests
277+
# @test getNeighbors(dfg, verts[1]) == [:x1x2f1]
278+
# neighbors = getNeighbors(dfg, getFactor(dfg, :x1x2f1))
279+
# @test neighbors == [:x1, :x2]
280+
# # Testing aliases
281+
# @test getNeighbors(dfg, getFactor(dfg, :x1x2f1)) == ls(dfg, getFactor(dfg, :x1x2f1))
282+
# @test getNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1)
283+
#
284+
# # ready and backendset
285+
# @test getNeighbors(dfg, :x5, ready=1) == Symbol[]
286+
# #TODO Confirm: test failed on GraphsDFG, don't know if the order is important for isa variable.
287+
# @test symdiff(getNeighbors(dfg, :x5, ready=0), [:x4x5f1,:x5x6f1]) == []
288+
# @test getNeighbors(dfg, :x5, backendset=1) == Symbol[]
289+
# @test symdiff(getNeighbors(dfg, :x5, backendset=0),[:x4x5f1,:x5x6f1]) == []
290+
# @test getNeighbors(dfg, :x7x8f1, ready=0) == [:x8]
291+
# @test getNeighbors(dfg, :x7x8f1, backendset=0) == [:x7]
292+
# @test getNeighbors(dfg, :x7x8f1, ready=1) == [:x7]
293+
# @test getNeighbors(dfg, :x7x8f1, backendset=1) == [:x8]
294+
# @test getNeighbors(dfg, verts[1], ready=0) == [:x1x2f1]
295+
# @test getNeighbors(dfg, verts[1], ready=1) == Symbol[]
296+
# @test getNeighbors(dfg, verts[1], backendset=0) == [:x1x2f1]
297+
# @test getNeighbors(dfg, verts[1], backendset=1) == Symbol[]
298+
#
299+
# end
300+
#
301+
# @testset "Getting Subgraphs" begin
302+
# # Subgraphs
303+
# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2)
304+
# # Only returns x1 and x2
305+
# @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
306+
# # Test include orphan factorsVoid
307+
# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 1, true)
308+
# @test symdiff([:x1, :x1x2f1], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
309+
# # Test adding to the dfg
310+
# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2, true, dfgSubgraph)
311+
# @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
312+
# #
313+
# dfgSubgraph = getSubgraph(dfg,[:x1, :x2, :x1x2f1])
314+
# # Only returns x1 and x2
315+
# @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
316+
#
317+
# # DFG issue #95 - confirming that getSubgraphAroundNode retains order
318+
# # REF: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/95
319+
# for fId in getVariableIds(dfg)
320+
# # Get a subgraph of this and it's related factors+variables
321+
# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2)
322+
# # For each factor check that the order the copied graph == original
323+
# for fact in getFactors(dfgSubgraph)
324+
# @test fact._variableOrderSymbols == getFactor(dfg, fact.label)._variableOrderSymbols
325+
# end
326+
# end
327+
# end
328+
#
329+
# @testset "Summaries and Summary Graphs" begin
330+
# factorFields = fieldnames(DFGFactorSummary)
331+
# variableFields = fieldnames(DFGVariableSummary)
332+
#
333+
# summary = getSummary(dfg)
334+
# @test symdiff(collect(keys(summary.variables)), ls(dfg)) == Symbol[]
335+
# @test symdiff(collect(keys(summary.factors)), lsf(dfg)) == Symbol[]
336+
#
337+
# summaryGraph = getSummaryGraph(dfg)
338+
# @test symdiff(ls(summaryGraph), ls(dfg)) == Symbol[]
339+
# @test symdiff(lsf(summaryGraph), lsf(dfg)) == Symbol[]
340+
# # Check all fields are equal for all variables
341+
# for v in ls(summaryGraph)
342+
# for field in variableFields
343+
# @test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
344+
# end
345+
# end
346+
# for f in lsf(summaryGraph)
347+
# for field in factorFields
348+
# @test getfield(getFactor(dfg, f), field) == getfield(getFactor(summaryGraph, f), field)
349+
# end
350+
# end
257351
# end
258-
259-
#change ready and backendset for x7,x8 for improved tests on x7x8f1
260-
verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes)
261-
#TODO fix this to use accessors
262-
verts[7].ready = 1
263-
# verts[7].backendset = 0
264-
verts[8].ready = 0
265-
verts[8].backendset = 1
266-
#call update to set it on cloud
267-
updateVariable!(dfg, verts[7])
268-
updateVariable!(dfg, verts[8])
269-
270-
facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1))
271-
272-
@testset "Getting Neighbors" begin
273-
global dfg,verts
274-
# Trivial test to validate that intersect([], []) returns order of first parameter
275-
@test intersect([:x3, :x2, :x1], [:x1, :x2]) == [:x2, :x1]
276-
# Get neighbors tests
277-
@test getNeighbors(dfg, verts[1]) == [:x1x2f1]
278-
neighbors = getNeighbors(dfg, getFactor(dfg, :x1x2f1))
279-
@test neighbors == [:x1, :x2]
280-
# Testing aliases
281-
@test getNeighbors(dfg, getFactor(dfg, :x1x2f1)) == ls(dfg, getFactor(dfg, :x1x2f1))
282-
@test getNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1)
283-
284-
# ready and backendset
285-
@test getNeighbors(dfg, :x5, ready=1) == Symbol[]
286-
#TODO Confirm: test failed on GraphsDFG, don't know if the order is important for isa variable.
287-
@test symdiff(getNeighbors(dfg, :x5, ready=0), [:x4x5f1,:x5x6f1]) == []
288-
@test getNeighbors(dfg, :x5, backendset=1) == Symbol[]
289-
@test symdiff(getNeighbors(dfg, :x5, backendset=0),[:x4x5f1,:x5x6f1]) == []
290-
@test getNeighbors(dfg, :x7x8f1, ready=0) == [:x8]
291-
@test getNeighbors(dfg, :x7x8f1, backendset=0) == [:x7]
292-
@test getNeighbors(dfg, :x7x8f1, ready=1) == [:x7]
293-
@test getNeighbors(dfg, :x7x8f1, backendset=1) == [:x8]
294-
@test getNeighbors(dfg, verts[1], ready=0) == [:x1x2f1]
295-
@test getNeighbors(dfg, verts[1], ready=1) == Symbol[]
296-
@test getNeighbors(dfg, verts[1], backendset=0) == [:x1x2f1]
297-
@test getNeighbors(dfg, verts[1], backendset=1) == Symbol[]
298-
299-
end
300-
301-
@testset "Getting Subgraphs" begin
302-
# Subgraphs
303-
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2)
304-
# Only returns x1 and x2
305-
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
306-
# Test include orphan factorsVoid
307-
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 1, true)
308-
@test symdiff([:x1, :x1x2f1], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
309-
# Test adding to the dfg
310-
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2, true, dfgSubgraph)
311-
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
312-
#
313-
dfgSubgraph = getSubgraph(dfg,[:x1, :x2, :x1x2f1])
314-
# Only returns x1 and x2
315-
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
316-
317-
# DFG issue #95 - confirming that getSubgraphAroundNode retains order
318-
# REF: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/95
319-
for fId in getVariableIds(dfg)
320-
# Get a subgraph of this and it's related factors+variables
321-
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2)
322-
# For each factor check that the order the copied graph == original
323-
for fact in getFactors(dfgSubgraph)
324-
@test fact._variableOrderSymbols == getFactor(dfg, fact.label)._variableOrderSymbols
325-
end
326-
end
327-
end
328-
329-
@testset "Summaries and Summary Graphs" begin
330-
factorFields = fieldnames(DFGFactorSummary)
331-
variableFields = fieldnames(DFGVariableSummary)
332-
333-
summary = getSummary(dfg)
334-
@test symdiff(collect(keys(summary.variables)), ls(dfg)) == Symbol[]
335-
@test symdiff(collect(keys(summary.factors)), lsf(dfg)) == Symbol[]
336-
337-
summaryGraph = getSummaryGraph(dfg)
338-
@test symdiff(ls(summaryGraph), ls(dfg)) == Symbol[]
339-
@test symdiff(lsf(summaryGraph), lsf(dfg)) == Symbol[]
340-
# Check all fields are equal for all variables
341-
for v in ls(summaryGraph)
342-
for field in variableFields
343-
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
344-
end
345-
end
346-
for f in lsf(summaryGraph)
347-
for field in factorFields
348-
@test getfield(getFactor(dfg, f), field) == getfield(getFactor(summaryGraph, f), field)
349-
end
350-
end
351-
end

test/sandbox.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ v3 = addVariable!(dfg, :c, ContinuousScalar, labels = [:LANDMARK])
2222
v4 = addVariable!(dfg, :d, ContinuousScalar, labels = [:LANDMARK])
2323
f1 = addFactor!(dfg, [:a; :b, :c, :d], LinearConditional(Normal(50.0,2.0)) )
2424
v1 == deepcopy(v1)
25-
v1 == getVariable(dfg, :a)
25+
v1_back == getVariable(dfg, :a)
26+
getNeighbors(f1)
27+
f1._variableOrderSymbols
2628

2729
T = typeof(dfg)
2830
if T <: CloudGraphsDFG

0 commit comments

Comments
 (0)