|
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
|
@@ -205,10 +207,11 @@ function compareAllSpecial(A::T1,
|
205 | 207 | skip=Symbol[],
|
206 | 208 | show::Bool=true) where {T1 <: GenericFunctionNodeData, T2 <: GenericFunctionNodeData}
|
207 | 209 | if T1 != T2
|
208 |
| - return false |
209 |
| - else |
210 |
| - return compareAll(A, B, skip=skip, show=show) |
| 210 | + @warn "compareAllSpecial is comparing different types" T1 T2 |
| 211 | + # return false |
| 212 | + # else |
211 | 213 | end
|
| 214 | + return compareAll(A, B, skip=skip, show=show) |
212 | 215 | end
|
213 | 216 |
|
214 | 217 |
|
@@ -241,21 +244,18 @@ function compareFactor(A::DFGFactor,
|
241 | 244 | #
|
242 | 245 | skip_ = union([:attributes;:solverData;:_variableOrderSymbols;:_gradients],skip)
|
243 | 246 | TP = compareAll(A, B, skip=skip_, show=show)
|
244 |
| - # TP = compareAll(A.label, B.label, skip=skip_, show=show) |
245 |
| - # TP = compareAll(A.timestamp, B.timestamp, skip=skip_, show=show) |
246 |
| - # TP = compareAll(A.nstime, B.nstime, skip=skip_, show=show) |
247 |
| - # TP = compareAll(A.tags, B.tags, skip=skip_, show=show) |
248 |
| - # TP = compareAll(A.solvable, B.solvable, skip=skip_, show=show) |
249 |
| - # TP = compareAll(A._variableOrderSymbols, B._variableOrderSymbols, skip=skip_, show=show) |
250 |
| - # TP = TP & compareAll(A.attributes, B.attributes, skip=[:data;], show=show) |
| 247 | + @debug "compareFactor 1/5" TP |
251 | 248 | TP = TP & compareAllSpecial(getSolverData(A), getSolverData(B), skip=union([:fnc;:_gradients], skip), show=show)
|
252 |
| - if :fnc in skip |
| 249 | + @debug "compareFactor 2/5" TP |
| 250 | + if !TP || :fnc in skip |
253 | 251 | return TP
|
254 | 252 | end
|
255 | 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 |
256 | 255 | if !(:measurement in skip)
|
257 |
| - 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)) |
258 | 257 | end
|
| 258 | + @debug "compareFactor 4/5" TP |
259 | 259 | if !(:params in skip)
|
260 | 260 | TP = TP & (skipcompute || compareAll(getSolverData(A).fnc.params, getSolverData(B).fnc.params, show=show, skip=skip))
|
261 | 261 | end
|
|
0 commit comments