1
1
# using Revise
2
+ # using Neo4j
3
+
4
+ # Debug logging
5
+ # using DistributedFactorGraphs
6
+ using Test
7
+ using Logging
2
8
using Neo4j
3
9
using DistributedFactorGraphs
4
10
using IncrementalInference
5
- using Test
6
- using Logging
7
- # Debug logging
8
11
logger = SimpleLogger (stdout , Logging. Debug)
9
12
global_logger (logger)
10
13
11
14
dfg = CloudGraphsDFG {SolverParams} (" localhost" , 7474 , " neo4j" , " test" ,
12
- " testUser" , " testRobot" , " sandbox " ,
15
+ " testUser" , " testRobot" , " testSession " ,
13
16
nothing ,
14
17
nothing ,
15
18
IncrementalInference. decodePackedType,
16
19
IncrementalInference. rebuildFactorMetadata!,
17
20
solverParams= SolverParams ())
18
- clearRobot!! (dfg)
19
21
22
+ if typeof (dfg) <: CloudGraphsDFG
23
+ @warn " TEST: Nuking all data for user '$(dfg. userId) ', robot '$(dfg. robotId) '!"
24
+ clearRobot!! (dfg)
25
+ end
26
+
27
+ # Same graph as iifInterfaceTests.jl
20
28
numNodes = 10
29
+
21
30
# change ready and backendset for x7,x8 for improved tests on x7x8f1
22
31
verts = map (n -> addVariable! (dfg, Symbol (" x$n " ), ContinuousScalar, labels = [:POSE ]), 1 : numNodes)
23
32
# TODO fix this to use accessors
@@ -31,25 +40,16 @@ updateVariable!(dfg, verts[8])
31
40
32
41
facts = map (n -> addFactor! (dfg, [verts[n], verts[n+ 1 ]], LinearConditional (Normal (50.0 ,2.0 ))), 1 : (numNodes- 1 ))
33
42
34
- # Get neighbors tests
35
- @test getNeighbors (dfg, verts[1 ]) == [:x1x2f1 ]
36
- neighbors = getNeighbors (dfg, getFactor (dfg, :x1x2f1 ))
37
- @test neighbors == [:x1 , :x2 ]
38
- # Testing aliases
39
- @test getNeighbors (dfg, getFactor (dfg, :x1x2f1 )) == ls (dfg, getFactor (dfg, :x1x2f1 ))
40
- @test getNeighbors (dfg, :x1x2f1 ) == ls (dfg, :x1x2f1 )
41
-
42
- # ready and backendset
43
- @test getNeighbors (dfg, :x5 , ready= 1 ) == Symbol[]
44
- # TODO Confirm: test failed on GraphsDFG, don't know if the order is important for isa variable.
45
- @test symdiff (getNeighbors (dfg, :x5 , ready= 0 ), [:x4x5f1 ,:x5x6f1 ]) == []
46
- @test getNeighbors (dfg, :x5 , backendset= 1 ) == Symbol[]
47
- @test symdiff (getNeighbors (dfg, :x5 , backendset= 0 ),[:x4x5f1 ,:x5x6f1 ]) == []
48
- @test getNeighbors (dfg, :x7x8f1 , ready= 0 ) == [:x8 ]
49
- @test getNeighbors (dfg, :x7x8f1 , backendset= 0 ) == [:x7 ]
50
- @test getNeighbors (dfg, :x7x8f1 , ready= 1 ) == [:x7 ]
51
- @test getNeighbors (dfg, :x7x8f1 , backendset= 1 ) == [:x8 ]
52
- @test getNeighbors (dfg, verts[1 ], ready= 0 ) == [:x1x2f1 ]
53
- @test getNeighbors (dfg, verts[1 ], ready= 1 ) == Symbol[]
54
- @test getNeighbors (dfg, verts[1 ], backendset= 0 ) == [:x1x2f1 ]
55
- @test getNeighbors (dfg, verts[1 ], backendset= 1 ) == Symbol[]
43
+ # Save and load the graph to test.
44
+ saveFolder = " /tmp/fileDFG"
45
+ saveDFG (dfg, saveFolder)
46
+
47
+ retDFG = loadDFG (saveFolder, Main)
48
+ @test symdiff (ls (dfg), ls (retDFG)) == []
49
+ @test symdiff (lsf (dfg), lsf (retDFG)) == []
50
+ for var in ls (dfg)
51
+ @test getVariable (dfg, var) == getVariable (retDFG, var)
52
+ end
53
+ for fact in lsf (dfg)
54
+ @test getFactor (dfg, fact) == getFactor (retDFG, fact)
55
+ end
0 commit comments