|
43 | 43 | """
|
44 | 44 | $(SIGNATURES)
|
45 | 45 |
|
46 |
| -Compare the all fields of T that are not in `skip` for objects `Al` and `Bl`. |
| 46 | +Compare the all fields of T that are not in `skip` for objects `Al` and `Bl` and returns `::Bool`. |
47 | 47 |
|
48 | 48 | TODO > add to func_ref.md
|
49 | 49 | """
|
50 |
| -function compareFields(Al::T, |
51 |
| - Bl::T; |
52 |
| - show::Bool=true, |
53 |
| - skip::Vector{Symbol}=Symbol[] )::Bool where {T} |
54 |
| - for field in fieldnames(T) |
| 50 | +function compareFields( Al::T1, |
| 51 | + Bl::T2; |
| 52 | + show::Bool=true, |
| 53 | + skip::Vector{Symbol}=Symbol[] ) where {T1,T2} |
| 54 | + # |
| 55 | + T1 == T2 ? nothing : @warn("different types in compareFields", T1, T2) |
| 56 | + for field in fieldnames(T1) |
55 | 57 | (field in skip) && continue
|
56 | 58 | tp = compareField(Al, Bl, field)
|
57 |
| - show && @debug(" $tp : $field")==nothing |
| 59 | + show && @debug(" $tp : $field") === nothing |
58 | 60 | !tp && return false
|
59 | 61 | end
|
60 | 62 | return true
|
61 | 63 | end
|
62 | 64 |
|
63 |
| -function compareFields(Al::T, |
64 |
| - Bl::T; |
65 |
| - show::Bool=true, |
66 |
| - skip::Vector{Symbol}=Symbol[] )::Bool where {T <: Union{Number, AbstractString}} |
| 65 | +function compareFields( Al::T, |
| 66 | + Bl::T; |
| 67 | + show::Bool=true, |
| 68 | + skip::Vector{Symbol}=Symbol[] )::Bool where {T <: Union{Number, AbstractString}} |
67 | 69 | #
|
68 | 70 | return Al == Bl
|
69 | 71 | end
|
@@ -130,12 +132,15 @@ function compareAll(Al::T,
|
130 | 132 | return true
|
131 | 133 | end
|
132 | 134 |
|
133 |
| -function compareAll(Al::T, Bl::T; show::Bool=true, skip::Vector{Symbol}=Symbol[]) where T |
134 |
| - @debug "Comparing types $T:" |
| 135 | +function compareAll(Al::T1, Bl::T2; show::Bool=true, skip::Vector{Symbol}=Symbol[]) where {T1,T2} |
| 136 | + @debug "Comparing types $T1, $T2" |
| 137 | + if T1 != T2 |
| 138 | + @warn "Types are different" T1 T2 |
| 139 | + end |
135 | 140 | # @debug " Al = $Al"
|
136 | 141 | # @debug " Bl = $Bl"
|
137 | 142 | !compareFields(Al, Bl, show=show, skip=skip) && return false
|
138 |
| - for field in fieldnames(T) |
| 143 | + for field in fieldnames(T1) |
139 | 144 | field in skip && continue
|
140 | 145 | @debug(" Checking field: $field")
|
141 | 146 | (!isdefined(Al, field) && !isdefined(Al, field)) && return true
|
@@ -202,10 +207,11 @@ function compareAllSpecial(A::T1,
|
202 | 207 | skip=Symbol[],
|
203 | 208 | show::Bool=true) where {T1 <: GenericFunctionNodeData, T2 <: GenericFunctionNodeData}
|
204 | 209 | if T1 != T2
|
205 |
| - return false |
206 |
| - else |
207 |
| - return compareAll(A, B, skip=skip, show=show) |
| 210 | + @warn "compareAllSpecial is comparing different types" T1 T2 |
| 211 | + # return false |
| 212 | + # else |
208 | 213 | end
|
| 214 | + return compareAll(A, B, skip=skip, show=show) |
209 | 215 | end
|
210 | 216 |
|
211 | 217 |
|
@@ -236,17 +242,20 @@ function compareFactor(A::DFGFactor,
|
236 | 242 | skipsamples::Bool=true,
|
237 | 243 | skipcompute::Bool=true )
|
238 | 244 | #
|
239 |
| - skip_ = |
240 |
| - TP = compareAll(A, B, skip=union([:attributes;:solverData;:_variableOrderSymbols;:_gradients],skip), show=show) |
241 |
| - # TP = TP & compareAll(A.attributes, B.attributes, skip=[:data;], show=show) |
| 245 | + skip_ = union([:attributes;:solverData;:_variableOrderSymbols;:_gradients],skip) |
| 246 | + TP = compareAll(A, B, skip=skip_, show=show) |
| 247 | + @debug "compareFactor 1/5" TP |
242 | 248 | TP = TP & compareAllSpecial(getSolverData(A), getSolverData(B), skip=union([:fnc;:_gradients], skip), show=show)
|
243 |
| - if :fnc in skip |
| 249 | + @debug "compareFactor 2/5" TP |
| 250 | + if !TP || :fnc in skip |
244 | 251 | return TP
|
245 | 252 | end
|
246 | 253 | TP = TP & compareAllSpecial(getSolverData(A).fnc, getSolverData(B).fnc, skip=union([:cpt;:measurement;:params;:varidx;:threadmodel;:_gradients], skip), show=show)
|
| 254 | + @debug "compareFactor 3/5" TP |
247 | 255 | if !(:measurement in skip)
|
248 |
| - TP = TP & (skipsamples || compareAll(getSolverData(A).fnc.measurement, getSolverData(B).fnc.measurement, show=show, skip=skip)) |
| 256 | + TP = TP & (skipsamples || compareAll(getSolverData(A).fnc.measurement, getSolverData(B).fnc.measurement, show=show, skip=skip)) |
249 | 257 | end
|
| 258 | + @debug "compareFactor 4/5" TP |
250 | 259 | if !(:params in skip)
|
251 | 260 | TP = TP & (skipcompute || compareAll(getSolverData(A).fnc.params, getSolverData(B).fnc.params, show=show, skip=skip))
|
252 | 261 | end
|
|
0 commit comments