Skip to content

Commit 6f4d3a0

Browse files
committed
cleanup dates, comment fix
1 parent 49e092f commit 6f4d3a0

File tree

2 files changed

+81
-90
lines changed

2 files changed

+81
-90
lines changed

LICENSE

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
Copyright (c) 2017-2022 NavAbility
2-
3-
The source code in this repository is separated into two parts
4-
that are licensed separately. The Neo4jDFG library/driver
5-
is licensed separately. For more details see:
6-
https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/blob/develop/src/Neo4jDFG/LICENSE
7-
8-
DistributedFactorGraphs' Neo4jDFG Driver is not licensed for hosted, webservice or cloud
9-
solutions (public or private). Please contact NavAbility via email at
10-
<[email protected]> for clarification or additional licensing options.
11-
NavAbility reserves all rights regarding, and to deny use of the software
12-
for hosted webservice or cloud offerings or deployments; over and above
13-
any conflicts that may arise with the licenses herein.
14-
15-
Other general use or modification of the software beyond that of
16-
webservices or clouds (private or public) is permitted
17-
according to terms defined by Apache 2.0 or other library specifc licenses.
18-
19-
Copyright 2017-2022 NavAbility
20-
21-
Licensed under the Apache License, Version 2.0 (the "License");
22-
you may not use this file except in compliance with the License.
23-
24-
Unless required by applicable law or agreed to in writing, software
25-
distributed under the License is distributed on an "AS IS" BASIS,
26-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27-
See the License for the specific language governing permissions and
28-
limitations under the License.
29-
1+
Copyright (c) 2017-2023 NavAbility Contributors
302

313
Apache License
324
Version 2.0, January 2004

src/services/CompareUtils.jl

Lines changed: 80 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ Recursively compare the all fields of T that are not in `skip` for objects `Al`
114114
115115
TODO > add to func_ref.md
116116
"""
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+
)
121123
#
122124
length(Al) != length(Bl) && return false
123125
for i in 1:length(Al)
@@ -161,34 +163,39 @@ function compareAll(Al::T1, Bl::T2; show::Bool=true, skip::Vector{Symbol}=Symbol
161163
end
162164

163165
#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
180185
end
181186

182187
"""
183188
$SIGNATURES
184189
185190
Compare that all fields are the same in a `::FactorGraph` variable.
186191
"""
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+
)
192199
#
193200
skiplist = union([:attributes;:solverDataDict;:createdTimestamp;:lastUpdatedTimestamp],skip)
194201
TP = compareAll(A, B, skip=skiplist, show=show)
@@ -206,13 +213,15 @@ function compareVariable(A::DFGVariable,
206213
TP = TP && compareAll(Ad, Bd, skip=varskiplist, show=show)
207214
TP = TP && typeof(getVariableType(Ad)) == typeof(getVariableType(Bd))
208215
TP = TP && compareAll(getVariableType(Ad), getVariableType(Bd), show=show, skip=skip)
209-
return TP
216+
return TP::Bool
210217
end
211218

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}
216225
if T1 != T2
217226
@warn "compareAllSpecial is comparing different types" T1 T2
218227
# return false
@@ -245,12 +254,14 @@ Compare that all fields are the same in a `::FactorGraph` factor.
245254
DevNotes
246255
- TODO `getSolverData(A).fnc.varValsAll / varidx` are only defined downstream, so should should this function not be in IIF?
247256
"""
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+
)
254265
#
255266
skip_ = union([:attributes;:solverData;:_variableOrderSymbols;:_gradients],skip)
256267
TP = compareAll(A, B, skip=skip_, show=show)
@@ -267,7 +278,7 @@ function compareFactor(A::DFGFactor,
267278
end
268279
@debug "compareFactor 4/5" TP
269280
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))
271282
end
272283
@debug "compareFactor 5/5" TP
273284
if !(:varidx in skip) && hasfield(typeof(getSolverData(A).fnc), :varidx) && getSolverData(A).fnc.varidx isa Base.RefValue
@@ -296,11 +307,13 @@ Related:
296307
297308
`compareFactorGraphs`, `compareSimilarVariables`, `compareVariable`, `ls`
298309
"""
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+
)
304317
# get all the variables in A or B
305318
xlA = listVariables(fgA)
306319
xlB = listVariables(fgB)
@@ -322,7 +335,7 @@ function compareAllVariables(fgA::G1,
322335
end
323336

324337
# return comparison result
325-
return TP
338+
return TP::Bool
326339
end
327340

328341
"""
@@ -337,11 +350,13 @@ Related:
337350
338351
`compareFactorGraphs`, `compareAllVariables`, `compareSimilarFactors`, `compareVariable`, `ls`.
339352
"""
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+
)
345360
#
346361
xlA = listVariables(fgA)
347362
xlB = listVariables(fgB)
@@ -357,7 +372,7 @@ function compareSimilarVariables(fgA::G1,
357372
end
358373

359374
# return comparison result
360-
return TP
375+
return TP::Bool
361376
end
362377

363378
"""
@@ -369,12 +384,14 @@ Related:
369384
370385
`compareFactorGraphs`, `compareSimilarVariables`, `compareAllVariables`, `ls`.
371386
"""
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+
)
378395
#
379396
xlA = listFactors(fgA)
380397
xlB = listFactors(fgB)
@@ -408,12 +425,14 @@ Related:
408425
409426
`compareSimilarVariables`, `compareSimilarFactors`, `compareAllVariables`, `ls`.
410427
"""
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+
)
417436
#
418437
skiplist = Symbol[:g;:bn;:IDs;:fIDs;:id;:nodeIDs;:factorIDs;:fifo;:solverParams; :factorOperationalMemoryType]
419438
skiplist = union(skiplist, skip)

0 commit comments

Comments
 (0)