@@ -114,10 +114,12 @@ Recursively compare the all fields of T that are not in `skip` for objects `Al`
114
114
115
115
TODO > add to func_ref.md
116
116
"""
117
- function compareAll (Al:: T ,
118
- Bl:: T ;
119
- show:: Bool = true ,
120
- skip:: Vector{Symbol} = Symbol[] ):: Bool where {T <: Tuple }
117
+ function compareAll (
118
+ Al:: Tuple ,
119
+ Bl:: Tuple ;
120
+ show:: Bool = true ,
121
+ skip:: Vector{Symbol} = Symbol[]
122
+ )
121
123
#
122
124
length (Al) != length (Bl) && return false
123
125
for i in 1 : length (Al)
@@ -161,34 +163,39 @@ function compareAll(Al::T1, Bl::T2; show::Bool=true, skip::Vector{Symbol}=Symbol
161
163
end
162
164
163
165
# Compare VariableNodeData
164
- function compare (a:: VariableNodeData , b:: VariableNodeData )
165
- a. val != b. val && @debug (" val is not equal" )== nothing && return false
166
- a. bw != b. bw && @debug (" bw is not equal" )== nothing && return false
167
- a. BayesNetOutVertIDs != b. BayesNetOutVertIDs && @debug (" BayesNetOutVertIDs is not equal" )== nothing && return false
168
- a. dimIDs != b. dimIDs && @debug (" dimIDs is not equal" )== nothing && return false
169
- a. dims != b. dims && @debug (" dims is not equal" )== nothing && return false
170
- a. eliminated != b. eliminated && @debug (" eliminated is not equal" )== nothing && return false
171
- a. BayesNetVertID != b. BayesNetVertID && @debug (" BayesNetVertID is not equal" )== nothing && return false
172
- a. separator != b. separator && @debug (" separator is not equal" )== nothing && return false
173
- a. initialized != b. initialized && @debug (" initialized is not equal" )== nothing && return false
174
- ! isapprox (a. infoPerCoord, b. infoPerCoord, atol= 1e-13 ) && @debug (" infoPerCoord is not equal" )== nothing && return false
175
- a. ismargin != b. ismargin && @debug (" ismargin is not equal" )== nothing && return false
176
- a. dontmargin != b. dontmargin && @debug (" dontmargin is not equal" )== nothing && return false
177
- a. solveInProgress != b. solveInProgress && @debug (" solveInProgress is not equal" )== nothing && return false
178
- getVariableType (a) != getVariableType (b) && @debug (" variableType is not equal" )== nothing && return false
179
- return true
166
+ function compare (
167
+ a:: VariableNodeData ,
168
+ b:: VariableNodeData
169
+ )
170
+ a. val != b. val && @debug (" val is not equal" )== nothing && return false
171
+ a. bw != b. bw && @debug (" bw is not equal" )== nothing && return false
172
+ a. BayesNetOutVertIDs != b. BayesNetOutVertIDs && @debug (" BayesNetOutVertIDs is not equal" )== nothing && return false
173
+ a. dimIDs != b. dimIDs && @debug (" dimIDs is not equal" )== nothing && return false
174
+ a. dims != b. dims && @debug (" dims is not equal" )== nothing && return false
175
+ a. eliminated != b. eliminated && @debug (" eliminated is not equal" )== nothing && return false
176
+ a. BayesNetVertID != b. BayesNetVertID && @debug (" BayesNetVertID is not equal" )== nothing && return false
177
+ a. separator != b. separator && @debug (" separator is not equal" )== nothing && return false
178
+ a. initialized != b. initialized && @debug (" initialized is not equal" )== nothing && return false
179
+ ! isapprox (a. infoPerCoord, b. infoPerCoord, atol= 1e-13 ) && @debug (" infoPerCoord is not equal" )== nothing && return false
180
+ a. ismargin != b. ismargin && @debug (" ismargin is not equal" )== nothing && return false
181
+ a. dontmargin != b. dontmargin && @debug (" dontmargin is not equal" )== nothing && return false
182
+ a. solveInProgress != b. solveInProgress && @debug (" solveInProgress is not equal" )== nothing && return false
183
+ getVariableType (a) != getVariableType (b) && @debug (" variableType is not equal" )== nothing && return false
184
+ return true
180
185
end
181
186
182
187
"""
183
188
$SIGNATURES
184
189
185
190
Compare that all fields are the same in a `::FactorGraph` variable.
186
191
"""
187
- function compareVariable (A:: DFGVariable ,
188
- B:: DFGVariable ;
189
- skip:: Vector{Symbol} = Symbol[],
190
- show:: Bool = true ,
191
- skipsamples:: Bool = true ):: Bool
192
+ function compareVariable (
193
+ A:: DFGVariable ,
194
+ B:: DFGVariable ;
195
+ skip:: Vector{Symbol} = Symbol[],
196
+ show:: Bool = true ,
197
+ skipsamples:: Bool = true
198
+ )
192
199
#
193
200
skiplist = union ([:attributes ;:solverDataDict ;:createdTimestamp ;:lastUpdatedTimestamp ],skip)
194
201
TP = compareAll (A, B, skip= skiplist, show= show)
@@ -206,13 +213,15 @@ function compareVariable(A::DFGVariable,
206
213
TP = TP && compareAll (Ad, Bd, skip= varskiplist, show= show)
207
214
TP = TP && typeof (getVariableType (Ad)) == typeof (getVariableType (Bd))
208
215
TP = TP && compareAll (getVariableType (Ad), getVariableType (Bd), show= show, skip= skip)
209
- return TP
216
+ return TP:: Bool
210
217
end
211
218
212
- function compareAllSpecial (A:: T1 ,
213
- B:: T2 ;
214
- skip= Symbol[],
215
- show:: Bool = true ) where {T1 <: GenericFunctionNodeData , T2 <: GenericFunctionNodeData }
219
+ function compareAllSpecial (
220
+ A:: T1 ,
221
+ B:: T2 ;
222
+ skip= Symbol[],
223
+ show:: Bool = true
224
+ ) where {T1 <: GenericFunctionNodeData , T2 <: GenericFunctionNodeData }
216
225
if T1 != T2
217
226
@warn " compareAllSpecial is comparing different types" T1 T2
218
227
# return false
@@ -245,12 +254,14 @@ Compare that all fields are the same in a `::FactorGraph` factor.
245
254
DevNotes
246
255
- TODO `getSolverData(A).fnc.varValsAll / varidx` are only defined downstream, so should should this function not be in IIF?
247
256
"""
248
- function compareFactor (A:: DFGFactor ,
249
- B:: DFGFactor ;
250
- show:: Bool = true ,
251
- skip:: Vector{Symbol} = Symbol[],
252
- skipsamples:: Bool = true ,
253
- skipcompute:: Bool = true )
257
+ function compareFactor (
258
+ A:: DFGFactor ,
259
+ B:: DFGFactor ;
260
+ show:: Bool = true ,
261
+ skip:: Vector{Symbol} = Symbol[],
262
+ skipsamples:: Bool = true ,
263
+ skipcompute:: Bool = true
264
+ )
254
265
#
255
266
skip_ = union ([:attributes ;:solverData ;:_variableOrderSymbols ;:_gradients ],skip)
256
267
TP = compareAll (A, B, skip= skip_, show= show)
@@ -267,7 +278,7 @@ function compareFactor(A::DFGFactor,
267
278
end
268
279
@debug " compareFactor 4/5" TP
269
280
if ! (:varValsAll in skip) && hasfield (typeof (getSolverData (A). fnc), :varValsAll )
270
- TP = TP & (skipcompute || compareAll (getSolverData (A). fnc. varValsAll[] , getSolverData (B). fnc. varValsAll[] , show= show, skip= skip))
281
+ TP = TP & (skipcompute || compareAll (getSolverData (A). fnc. varValsAll, getSolverData (B). fnc. varValsAll, show= show, skip= skip))
271
282
end
272
283
@debug " compareFactor 5/5" TP
273
284
if ! (:varidx in skip) && hasfield (typeof (getSolverData (A). fnc), :varidx ) && getSolverData (A). fnc. varidx isa Base. RefValue
@@ -296,11 +307,13 @@ Related:
296
307
297
308
`compareFactorGraphs`, `compareSimilarVariables`, `compareVariable`, `ls`
298
309
"""
299
- function compareAllVariables (fgA:: G1 ,
300
- fgB:: G2 ;
301
- skip:: Vector{Symbol} = Symbol[],
302
- show:: Bool = true ,
303
- skipsamples:: Bool = true ):: Bool where {G1 <: AbstractDFG , G2 <: AbstractDFG }
310
+ function compareAllVariables (
311
+ fgA:: AbstractDFG ,
312
+ fgB:: AbstractDFG ;
313
+ skip:: Vector{Symbol} = Symbol[],
314
+ show:: Bool = true ,
315
+ skipsamples:: Bool = true
316
+ )
304
317
# get all the variables in A or B
305
318
xlA = listVariables (fgA)
306
319
xlB = listVariables (fgB)
@@ -322,7 +335,7 @@ function compareAllVariables(fgA::G1,
322
335
end
323
336
324
337
# return comparison result
325
- return TP
338
+ return TP:: Bool
326
339
end
327
340
328
341
"""
@@ -337,11 +350,13 @@ Related:
337
350
338
351
`compareFactorGraphs`, `compareAllVariables`, `compareSimilarFactors`, `compareVariable`, `ls`.
339
352
"""
340
- function compareSimilarVariables (fgA:: G1 ,
341
- fgB:: G2 ;
342
- skip:: Vector{Symbol} = Symbol[],
343
- show:: Bool = true ,
344
- skipsamples:: Bool = true ):: Bool where {G1 <: AbstractDFG , G2 <: AbstractDFG }
353
+ function compareSimilarVariables (
354
+ fgA:: AbstractDFG ,
355
+ fgB:: AbstractDFG ;
356
+ skip:: Vector{Symbol} = Symbol[],
357
+ show:: Bool = true ,
358
+ skipsamples:: Bool = true
359
+ )
345
360
#
346
361
xlA = listVariables (fgA)
347
362
xlB = listVariables (fgB)
@@ -357,7 +372,7 @@ function compareSimilarVariables(fgA::G1,
357
372
end
358
373
359
374
# return comparison result
360
- return TP
375
+ return TP:: Bool
361
376
end
362
377
363
378
"""
@@ -369,12 +384,14 @@ Related:
369
384
370
385
`compareFactorGraphs`, `compareSimilarVariables`, `compareAllVariables`, `ls`.
371
386
"""
372
- function compareSimilarFactors ( fgA:: G1 ,
373
- fgB:: G2 ;
374
- skipsamples:: Bool = true ,
375
- skipcompute:: Bool = true ,
376
- skip:: AbstractVector{Symbol} = Symbol[],
377
- show:: Bool = true ) where {G1 <: AbstractDFG , G2 <: AbstractDFG }
387
+ function compareSimilarFactors (
388
+ fgA:: AbstractDFG ,
389
+ fgB:: AbstractDFG ;
390
+ skipsamples:: Bool = true ,
391
+ skipcompute:: Bool = true ,
392
+ skip:: AbstractVector{Symbol} = Symbol[],
393
+ show:: Bool = true
394
+ )
378
395
#
379
396
xlA = listFactors (fgA)
380
397
xlB = listFactors (fgB)
@@ -408,12 +425,14 @@ Related:
408
425
409
426
`compareSimilarVariables`, `compareSimilarFactors`, `compareAllVariables`, `ls`.
410
427
"""
411
- function compareFactorGraphs ( fgA:: G1 ,
412
- fgB:: G2 ;
413
- skipsamples:: Bool = true ,
414
- skipcompute:: Bool = true ,
415
- skip:: Vector{Symbol} = Symbol[],
416
- show:: Bool = true ) where {G1 <: AbstractDFG , G2 <: AbstractDFG }
428
+ function compareFactorGraphs (
429
+ fgA:: AbstractDFG ,
430
+ fgB:: AbstractDFG ;
431
+ skipsamples:: Bool = true ,
432
+ skipcompute:: Bool = true ,
433
+ skip:: Vector{Symbol} = Symbol[],
434
+ show:: Bool = true
435
+ )
417
436
#
418
437
skiplist = Symbol[:g ;:bn ;:IDs ;:fIDs ;:id ;:nodeIDs ;:factorIDs ;:fifo ;:solverParams ; :factorOperationalMemoryType ]
419
438
skiplist = union (skiplist, skip)
0 commit comments