1
+ # # @generated compare
2
+ # Reference https://github.com/JuliaLang/julia/issues/4648
3
+
4
+ import Base.==
5
+
6
+ #=
7
+ TODO <:InferenceVariable: please someone confirm this, I'm not fully up to date why softtype was created.
8
+ For now abstract `InferenceVariable`s are considered equal if they are the same type (except for labels, that I feel are deprecated)
9
+ If your implentation has aditional properties such as `DynPose2` with `ut::Int64` (microsecond time) or support different manifolds
10
+ implement compare if needed. softtype sounds a bit if it can be a trait, or in the future, rather a normal julia type.
11
+ =#
12
+ == (a:: InferenceVariable ,b:: InferenceVariable ) = typeof (a) == typeof (b)
13
+
14
+ == (a:: ConvolutionObject , b:: ConvolutionObject ) = typeof (a) == typeof (b)
15
+
16
+ == (a:: FunctorInferenceType , b:: FunctorInferenceType ) = typeof (a) == typeof (b)
17
+
18
+ # TestCCW1{TestFunctorInferenceType1}
19
+
20
+ # Generate compares automatically for all in this union
21
+ const GeneratedCompareUnion = Union{MeanMaxPPE, VariableNodeData, DFGNodeParams,
22
+ DFGVariable, DFGVariableSummary, SkeletonDFGVariable,
23
+ GenericFunctionNodeData,
24
+ DFGFactor, DFGFactorSummary, SkeletonDFGFactor}
25
+
26
+ @generated function == (x:: T , y:: T ) where T <: GeneratedCompareUnion
27
+ mapreduce (n -> :(x.$ n == y.$ n), (a,b)-> :($ a && $ b), fieldnames (x))
28
+ end
29
+
30
+
31
+ # #
1
32
2
33
function compareField (Allc, Bllc, syms):: Bool
3
- (! isdefined (Allc, syms) && ! isdefined (Bllc, syms)) && return true
4
- ! isdefined (Allc, syms) && return false
5
- ! isdefined (Bllc, syms) && return false
6
- return eval (:($ Allc.$ syms == $ Bllc.$ syms))
34
+ (! isdefined (Allc, syms) && ! isdefined (Bllc, syms)) && return true
35
+ ! isdefined (Allc, syms) && return false
36
+ ! isdefined (Bllc, syms) && return false
37
+ return eval (:($ Allc.$ syms == $ Bllc.$ syms))
7
38
end
8
39
9
40
"""
@@ -114,6 +145,25 @@ function compareAll(Al::T, Bl::T; show::Bool=true, skip::Vector{Symbol}=Symbol[]
114
145
return true
115
146
end
116
147
148
+ # Compare VariableNodeData
149
+ function compare (a:: VariableNodeData , b:: VariableNodeData )
150
+ a. val != b. val && @debug (" val is not equal" )== nothing && return false
151
+ a. bw != b. bw && @debug (" bw is not equal" )== nothing && return false
152
+ a. BayesNetOutVertIDs != b. BayesNetOutVertIDs && @debug (" BayesNetOutVertIDs is not equal" )== nothing && return false
153
+ a. dimIDs != b. dimIDs && @debug (" dimIDs is not equal" )== nothing && return false
154
+ a. dims != b. dims && @debug (" dims is not equal" )== nothing && return false
155
+ a. eliminated != b. eliminated && @debug (" eliminated is not equal" )== nothing && return false
156
+ a. BayesNetVertID != b. BayesNetVertID && @debug (" BayesNetVertID is not equal" )== nothing && return false
157
+ a. separator != b. separator && @debug (" separator is not equal" )== nothing && return false
158
+ a. initialized != b. initialized && @debug (" initialized is not equal" )== nothing && return false
159
+ abs (a. inferdim - b. inferdim) > 1e-14 && @debug (" inferdim is not equal" )== nothing && return false
160
+ a. ismargin != b. ismargin && @debug (" ismargin is not equal" )== nothing && return false
161
+ a. dontmargin != b. dontmargin && @debug (" dontmargin is not equal" )== nothing && return false
162
+ a. solveInProgress != b. solveInProgress && @debug (" solveInProgress is not equal" )== nothing && return false
163
+ typeof (a. softtype) != typeof (b. softtype) && @debug (" softtype is not equal" )== nothing && return false
164
+ return true
165
+ end
166
+
117
167
"""
118
168
$SIGNATURES
119
169
@@ -155,6 +205,20 @@ function compareAllSpecial(A::T1,
155
205
end
156
206
end
157
207
208
+
209
+ # Compare FunctionNodeData
210
+ function compare (a:: GenericFunctionNodeData{T1,S} ,b:: GenericFunctionNodeData{T2,S} ) where {T1, T2, S}
211
+ # TODO -- beef up this comparison to include the gwp
212
+ TP = true
213
+ TP = TP && a. fncargvID == b. fncargvID
214
+ TP = TP && a. eliminated == b. eliminated
215
+ TP = TP && a. potentialused == b. potentialused
216
+ TP = TP && a. edgeIDs == b. edgeIDs
217
+ TP = TP && a. frommodule == b. frommodule
218
+ # TP = TP && typeof(a.fnc) == typeof(b.fnc)
219
+ return TP
220
+ end
221
+
158
222
"""
159
223
$SIGNATURES
160
224
@@ -167,7 +231,7 @@ function compareFactor(A::DFGFactor,
167
231
skipsamples:: Bool = true ,
168
232
skipcompute:: Bool = true )
169
233
#
170
- TP = compareAll (A, B, skip= union ([:attributes ;:data ;:_variableOrderSymbols ;:_internalId ],skip), show= show)
234
+ TP = compareAll (A, B, skip= union ([:attributes ;:solverData ;:_variableOrderSymbols ;:_internalId ],skip), show= show)
171
235
# TP = TP & compareAll(A.attributes, B.attributes, skip=[:data;], show=show)
172
236
TP = TP & compareAllSpecial (getSolverData (A), getSolverData (B), skip= union ([:fnc ;:_internalId ], skip), show= show)
173
237
TP = TP & compareAllSpecial (getSolverData (A). fnc, getSolverData (B). fnc, skip= union ([:cpt ;:measurement ;:params ;:varidx ;:threadmodel ], skip), show= show)
@@ -323,3 +387,16 @@ function compareFactorGraphs(fgA::G1,
323
387
324
388
return TP
325
389
end
390
+
391
+
392
+ # """
393
+ # ==(x::T, y::T) where T <: AbstractPointParametricEst
394
+ # Equality check for AbstractPointParametricEst.
395
+ # """
396
+ # @generated function ==(x::T, y::T) where T <: AbstractPointParametricEst
397
+ # mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
398
+ # end
399
+ #
400
+ # @generated function Base.:(==)(x::T, y::T) where T <: Union{DFGFactorSummary, DFGVariableSummary, SkeletonDFGVariable, SkeletonDFGFactor}
401
+ # mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
402
+ # end
0 commit comments