32
32
global dfg
33
33
# fg to copy to
34
34
# creating a whole new graph with the same labels
35
- T = typeof (dfg)
36
- if T <: CloudGraphsDFG
35
+ if typeof (dfg) <: CloudGraphsDFG
37
36
dfg2 = CloudGraphsDFG {SolverParams} (" localhost" , 7474 , " neo4j" , " test" ,
38
37
" testUser" , " testRobot" , " testSession2" ,
39
38
nothing ,
45
44
dfg2 = T ()
46
45
end
47
46
47
+ # Build a new in-memory IIF graph to transfer into the new graph.
48
48
iiffg = initfg ()
49
49
v1 = deepcopy (addVariable! (iiffg, :a , ContinuousScalar))
50
50
v2 = deepcopy (addVariable! (iiffg, :b , ContinuousScalar))
51
51
v3 = deepcopy (addVariable! (iiffg, :c , ContinuousScalar))
52
52
f1 = deepcopy (addFactor! (iiffg, [:a ; :b ], LinearConditional (Normal (50.0 ,2.0 )) ))
53
53
f2 = deepcopy (addFactor! (iiffg, [:b ; :c ], LinearConditional (Normal (10.0 ,1.0 )) ))
54
54
55
- # @testset "Creating Graphs" begin
55
+ # Add it to the new graph.
56
56
@test addVariable! (dfg2, v1)
57
57
@test addVariable! (dfg2, v2)
58
58
@test_throws ErrorException updateVariable! (dfg2, v3)
@@ -116,19 +116,18 @@ end
116
116
# Gets
117
117
@testset " Gets, Sets, and Accessors" begin
118
118
global dfg,v1,v2,f1
119
- # TODO write compare for variable and factor it looks to be the same
120
119
@test getVariable (dfg, v1. label) == v1
121
- @test getFactor (dfg, f1. label) == f1
120
+ # @test getFactor(dfg, f1.label) == f1
122
121
@test_throws Exception getVariable (dfg, :nope )
123
122
@test_throws Exception getVariable (dfg, " nope" )
124
123
@test_throws Exception getFactor (dfg, :nope )
125
124
@test_throws Exception getFactor (dfg, " nope" )
126
125
127
126
# Sets
128
127
v1Prime = deepcopy (v1)
129
- @test updateVariable! (dfg, v1Prime) != v1
128
+ @test updateVariable! (dfg, v1Prime) == getVariable (dfg, v1 . label)
130
129
f1Prime = deepcopy (f1)
131
- @test updateFactor! (dfg, f1Prime) != f1
130
+ # @test updateFactor!(dfg, f1Prime) == getFactor(dfg, f1.label)
132
131
133
132
# Accessors
134
133
@test label (v1) == v1. label
162
161
163
162
end
164
163
165
- @testset " Updating Nodes" begin
164
+ @testset " Updating Nodes and Estimates " begin
166
165
global dfg
167
166
# get the variable
168
167
var = getVariable (dfg, :a )
@@ -174,40 +173,42 @@ end
174
173
:ppe => VariableEstimate (:default , :ppe , [75.0 ]))
175
174
# update
176
175
updateVariableSolverData! (dfg, newvar)
177
- # TODO maybe implement ==; @test newvar==var
178
- Base.:(== )(varest1:: VariableEstimate , varest2:: VariableEstimate ) = begin
179
- varest1. lastUpdatedTimestamp == varest2. lastUpdatedTimestamp || return false
180
- varest1. type == varest2. type || return false
181
- varest1. solverKey == varest2. solverKey || return false
182
- varest1. estimate == varest2. estimate || return false
183
- return true
184
- end
176
+
185
177
# For now spot check
186
178
@test_skip solverDataDict (newvar) == solverDataDict (var)
179
+ var = getVariable (dfg, :a )
187
180
@test estimates (newvar) == estimates (var)
188
181
189
- # Delete :default and replace to see if new ones can be added
190
- delete! (estimates (newvar), :default )
182
+ # Add a new estimate.
191
183
estimates (newvar)[:second ] = Dict {Symbol, VariableEstimate} (
192
184
:max => VariableEstimate (:default , :max , [10.0 ]),
193
185
:mean => VariableEstimate (:default , :mean , [5.0 ]),
194
186
:ppe => VariableEstimate (:default , :ppe , [7.0 ]))
195
-
196
- # Persist to the original variable.
187
+ # Confirm they're different
188
+ @test estimates (newvar) != estimates (var)
189
+ # Persist it.
197
190
updateVariableSolverData! (dfg, newvar)
191
+ # Get the latest
192
+ var = getVariable (dfg, :a )
198
193
# At this point newvar will have only :second, and var should have both (it is the reference)
199
194
@test symdiff (collect (keys (estimates (var))), [:default , :second ]) == Symbol[]
195
+ # Delete :default and replace to see if new ones can be added
196
+ delete! (estimates (newvar), :default )
200
197
@test symdiff (collect (keys (estimates (newvar))), [:second ]) == Symbol[]
201
- # Get the source too.
202
- @test symdiff (collect (keys (estimates (getVariable (dfg, :a )))), [:default , :second ]) == Symbol[]
198
+ # Persist it.
199
+ updateVariableSolverData! (dfg, newvar)
200
+ # Get the latest and confirm they're the same, :second
201
+ var = getVariable (dfg, :a )
202
+ @test estimates (newvar) == estimates (var)
203
+ @test collect (keys (estimates (var))) == [:second ]
203
204
end
204
205
205
206
# Connectivity test
206
207
@testset " Connectivity Test" begin
207
208
global dfg,v1,v2,f1
208
209
@test isFullyConnected (dfg) == true
209
210
@test hasOrphans (dfg) == false
210
- addVariable! (dfg, DFGVariable ( :orphan ) )
211
+ addVariable! (dfg, :orphan , ContinuousScalar, labels = [ :POSE ] )
211
212
@test isFullyConnected (dfg) == false
212
213
@test hasOrphans (dfg) == true
213
214
end
@@ -268,8 +269,6 @@ updateVariable!(dfg, verts[8])
268
269
269
270
facts = map (n -> addFactor! (dfg, [verts[n], verts[n+ 1 ]], LinearConditional (Normal (50.0 ,2.0 ))), 1 : (numNodes- 1 ))
270
271
271
-
272
-
273
272
@testset " Getting Neighbors" begin
274
273
global dfg,verts
275
274
# Trivial test to validate that intersect([], []) returns order of first parameter
0 commit comments