@@ -16,130 +16,40 @@ dfg = CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test",
16
16
IncrementalInference. rebuildFactorMetadata!,
17
17
solverParams= SolverParams ())
18
18
clearRobot!! (dfg)
19
- v1 = addVariable! (dfg, :a , ContinuousScalar, labels = [:POSE ])
20
- v2 = addVariable! (dfg, :b , ContinuousScalar, labels = [:LANDMARK ])
21
- v3 = addVariable! (dfg, :c , ContinuousScalar, labels = [:LANDMARK ])
22
- v4 = addVariable! (dfg, :d , ContinuousScalar, labels = [:LANDMARK ])
23
- f1 = addFactor! (dfg, [:a ; :b , :c , :d ], LinearConditional (Normal (50.0 ,2.0 )) )
24
- v1 == deepcopy (v1)
25
- v1_back == getVariable (dfg, :a )
26
- getNeighbors (f1)
27
- f1. _variableOrderSymbols
28
19
29
- T = typeof (dfg)
30
- if T <: CloudGraphsDFG
31
- dfg2 = CloudGraphsDFG {SolverParams} (" localhost" , 7474 , " neo4j" , " test" ,
32
- " testUser" , " testRobot" , " testSession2" ,
33
- nothing ,
34
- nothing ,
35
- IncrementalInference. decodePackedType,
36
- IncrementalInference. rebuildFactorMetadata!,
37
- solverParams= SolverParams ())
38
- else
39
- dfg2 = T ()
40
- end
41
- iiffg = initfg ()
42
- v1 = deepcopy (addVariable! (iiffg, :a , ContinuousScalar))
43
- v2 = deepcopy (addVariable! (iiffg, :b , ContinuousScalar))
44
- v3 = deepcopy (addVariable! (iiffg, :c , ContinuousScalar))
45
- f1 = deepcopy (addFactor! (iiffg, [:a ; :b ], LinearConditional (Normal (50.0 ,2.0 )) ))
46
- f2 = deepcopy (addFactor! (iiffg, [:b ; :c ], LinearConditional (Normal (10.0 ,1.0 )) ))
47
-
48
- # @testset "Creating Graphs" begin
49
- @test addVariable! (dfg2, v1)
50
- @test addVariable! (dfg2, v2)
51
- @test_throws ErrorException updateVariable! (dfg2, v3)
52
- @test addVariable! (dfg2, v3)
53
- @test_throws ErrorException addVariable! (dfg2, v3)
54
- @test addFactor! (dfg2, [v1, v2], f1)
55
- @test_throws ErrorException addFactor! (dfg2, [v1, v2], f1)
56
- @test_throws ErrorException updateFactor! (dfg2, f2)
57
- @test addFactor! (dfg2, [:b , :c ], f2)
58
-
59
- dv3 = deleteVariable! (dfg2, v3)
60
- # TODO write compare if we want to compare complete one, for now just label
61
- # @test dv3 == v3
62
- @test dv3. label == v3. label
63
- @test_throws ErrorException deleteVariable! (dfg2, v3)
64
-
65
- @test symdiff (ls (dfg2),[:a ,:b ]) == []
66
- df2 = deleteFactor! (dfg2, f2)
67
- # TODO write compare if we want to compare complete one, for now just label
68
- # @test df2 == f2
69
- @test df2. label == f2. label
70
- @test_throws ErrorException deleteFactor! (dfg2, f2)
71
-
72
- @test lsf (dfg2) == [:abf1 ]
73
-
74
- @test length (ls (dfg)) == 2
75
- @test length (lsf (dfg)) == 1 # Unless we add the prior!
76
- @test symdiff ([:a , :b ], getVariableIds (dfg)) == []
77
- @test getFactorIds (dfg) == [:abf1 ] # Unless we add the prior!
78
- #
79
- @test lsf (dfg, :a ) == [f1. label]
80
- # Tags
81
- @test ls (dfg, tags= [:POSE ]) == [:a ]
82
- @test symdiff (ls (dfg, tags= [:POSE , :LANDMARK ]), ls (dfg, tags= [:VARIABLE ])) == []
83
- # Regexes
84
- @test ls (dfg, r" a" ) == [v1. label]
85
- # TODO : Check that this regular expression works on everything else!
86
- # it works with the .
87
- # REF: https://stackoverflow.com/questions/23834692/using-regular-expression-in-neo4j
88
- @test lsf (dfg, r" abf.*" ) == [f1. label]
89
-
90
- # Accessors
91
- @test getAddHistory (dfg) == [:a , :b ] # , :abf1
92
- @test getDescription (dfg) != nothing
93
- @test getLabelDict (dfg) != nothing
94
- # Existence
95
- @test exists (dfg, :a ) == true
96
- @test exists (dfg, v1) == true
97
- @test exists (dfg, :nope ) == false
98
- # Sorting of results
99
- # TODO - this function needs to be cleaned up
100
- unsorted = [:x1_3 ;:x1_6 ;:l1 ;:april1 ] # this will not work for :x1x2f1
101
- @test sortDFG (unsorted) == sortVarNested (unsorted)
102
- @test_skip sortDFG ([:x1x2f1 , :x1l1f1 ]) == [:x1l1f1 , :x1x2f1 ]
103
-
104
- @test getVariable (dfg, v1. label) == v1
105
- @test getFactor (dfg, f1. label) == f1
106
- @test_throws Exception getVariable (dfg, :nope )
107
- @test_throws Exception getVariable (dfg, " nope" )
108
- @test_throws Exception getFactor (dfg, :nope )
109
- @test_throws Exception getFactor (dfg, " nope" )
110
-
111
- # Sets
112
- v1Prime = deepcopy (v1)
113
- @test updateVariable! (dfg, v1Prime) != v1
114
- f1Prime = deepcopy (f1)
115
- @test updateFactor! (dfg, f1Prime) != f1
116
-
117
- # Accessors
118
- @test label (v1) == v1. label
119
- @test tags (v1) == v1. tags
120
- @test timestamp (v1) == v1. timestamp
121
- @test estimates (v1) == v1. estimateDict
122
- @test DistributedFactorGraphs. estimate (v1, :notfound ) == nothing
123
- @test solverData (v1) === v1. solverDataDict[:default ]
124
- @test getData (v1) === v1. solverDataDict[:default ]
125
- @test solverData (v1, :default ) === v1. solverDataDict[:default ]
126
- @test solverDataDict (v1) == v1. solverDataDict
127
- @test internalId (v1) == v1. _internalId
128
-
129
- @test label (f1) == f1. label
130
- @test tags (f1) == f1. tags
131
- @test solverData (f1) == f1. data
132
- # Deprecated functions
133
- @test data (f1) == f1. data
134
- @test getData (f1) == f1. data
135
- # Internal function
136
- @test internalId (f1) == f1. _internalId
137
-
138
- @test getSolverParams (dfg) != nothing
139
- @test setSolverParams (dfg, getSolverParams (dfg)) == getSolverParams (dfg)
140
-
141
- # solver data is initialized
142
- @test ! isInitialized (dfg, :a )
143
- @test ! isInitialized (v2)
144
-
145
- @test ! isInitialized (v2, key= :second )
20
+ numNodes = 10
21
+ # change ready and backendset for x7,x8 for improved tests on x7x8f1
22
+ verts = map (n -> addVariable! (dfg, Symbol (" x$n " ), ContinuousScalar, labels = [:POSE ]), 1 : numNodes)
23
+ # TODO fix this to use accessors
24
+ verts[7 ]. ready = 1
25
+ # verts[7].backendset = 0
26
+ verts[8 ]. ready = 0
27
+ verts[8 ]. backendset = 1
28
+ # call update to set it on cloud
29
+ updateVariable! (dfg, verts[7 ])
30
+ updateVariable! (dfg, verts[8 ])
31
+
32
+ facts = map (n -> addFactor! (dfg, [verts[n], verts[n+ 1 ]], LinearConditional (Normal (50.0 ,2.0 ))), 1 : (numNodes- 1 ))
33
+
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[]
0 commit comments