-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiifCompareTests.jl
117 lines (85 loc) · 2.95 KB
/
iifCompareTests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# IIF testCompareVariableFactors repeated in IIF
using DistributedFactorGraphs
using IncrementalInference
using Test
@testset "testing compare functions for variables and factors..." begin
fg = initfg()
v1 = addVariable!(fg, :x0, ContinuousScalar)
f1 = addFactor!(fg, [:x0;], Prior(Normal()))
@test compareVariable(v1, v1)
@test compareFactor(f1, f1)
v2 = addVariable!(fg, :x1, ContinuousScalar)
f2 = addFactor!(fg, [:x0; :x1], LinearRelative(Normal(2.0, 0.1)))
fg2 = deepcopy(fg)
@test !compareVariable(v1, v2)
# not testing different factors in this way
# @test !compareFactor(f1,f2)
@test compareAllVariables(fg, fg)
@test compareAllVariables(fg, fg2)
@test compareSimilarVariables(fg, fg)
@test compareSimilarVariables(fg, fg2)
@test compareSimilarFactors(fg, fg)
@test compareSimilarFactors(fg, fg2)
@test compareFactorGraphs(fg, fg)
@test compareFactorGraphs(fg, fg2)
tree = solveTree!(fg)
x1a = getVariable(fg, :x0)
x1b = getVariable(fg2, :x0)
@test !compareVariable(x1a, x1b; skipsamples = false)
@test !compareSimilarVariables(fg, fg2; skipsamples = false)
@test !compareSimilarFactors(fg, fg2; skipsamples = false)
@test compareFactorGraphs(fg, fg)
@test !compareFactorGraphs(fg, fg2; skipsamples = false)
initAll!(fg2)
@test compareSimilarVariables(
fg,
fg2,
skipsamples = true,
skip = Symbol[:infoPerCoord; :initialized; :inferdim; :ppeDict; :solvedCount],
)
# fg2 has been solved, so it should fail on the estimate dictionary
@test !compareSimilarVariables(
fg,
fg2;
skipsamples = true,
skip = Symbol[:initialized; :inferdim],
)
tree = buildTreeReset!(fg2)
@test compareSimilarFactors(
fg,
fg2,
skipsamples = true,
skipcompute = true,
skip = [:fullvariables],
)
@test !compareSimilarFactors(fg, fg2; skipsamples = true, skipcompute = false)
@test compareFactorGraphs(
fg,
fg2,
skipsamples = true,
skipcompute = true,
skip = [
:fullvariables
:infoPerCoord
:initialized
:inferdim
:ppeDict
:solvedCount
],
)
end
@testset "test subgraph functions..." begin
fg = initfg()
addVariable!(fg, :x0, ContinuousScalar)
addFactor!(fg, [:x0;], Prior(Normal()))
addVariable!(fg, :x1, ContinuousScalar)
addFactor!(fg, [:x0; :x1], LinearRelative(Normal(2.0, 0.1)))
addVariable!(fg, :x2, ContinuousScalar)
addFactor!(fg, [:x1; :x2], LinearRelative(Normal(4.0, 0.1)))
addVariable!(fg, :l1, ContinuousScalar)
addFactor!(fg, [:x1; :l1], LinearRelative(Rayleigh()))
sfg = buildSubgraph(GraphsDFG, fg, [:x0; :x1])
@warn "FIXME This is NOT supposed to pass"
@test_skip compareFactorGraphs(fg, sfg, skip = [:labelDict; :addHistory; :logpath])
# drawGraph(sfg)
end