@@ -17,43 +17,39 @@ using Test
17
17
# Same graph as iifInterfaceTests.jl
18
18
numNodes = 5
19
19
20
- # change ready and solvable for x7,x8 for improved tests on x7x8f1
20
+ # Arranging some random data
21
21
verts = map (n -> addVariable! (dfg, Symbol (" x$n " ), ContinuousScalar, labels = [:POSE ]), 1 : numNodes)
22
- # TODO fix this to use accessors
23
- verts[3 ]. solvable = 1
24
- verts[4 ]. solvable = 0
25
- getSolverData (verts[4 ]). solveInProgress = 1
26
- # call update to set it on cloud
27
- updateVariable! (dfg, verts[3 ])
28
- updateVariable! (dfg, verts[4 ])
22
+ map (v -> setSolvable! (v, Int (round (rand ()))), verts)
23
+ map (v -> getSolverData (verts[4 ]). solveInProgress= Int (round (rand ())), verts)
24
+ map (v -> setSolvedCount! (v, Int (round (10 * rand ()))), verts)
29
25
30
- setSolvedCount! (verts[1 ], 5 )
31
- # Add some data entries to x1, x2
26
+ # Add some data entries
27
+ map (v -> addDataEntry! (v, BlobStoreEntry (:testing , uuid4 (), :store , " " , " " , " " , " " , now (localzone ()))), verts)
28
+ map (v -> addDataEntry! (v, BlobStoreEntry (:testing2 , uuid4 (), :store , " " , " " , " " , " " , ZonedDateTime (2014 , 5 , 30 , 21 , tz " UTC-4" ))), verts)
32
29
33
- # FIXME part of broken test at the bottom
34
- # addDataEntry!(verts[1], BlobStoreEntry(:testing, uuid4(), :store, "", "", "", "", now(localzone())))
35
- # addDataEntry!(verts[2], BlobStoreEntry(:testing2, uuid4(), :store, "", "", "", "", now(localzone())))
30
+ # Add some PPEs
31
+ ppe1 = MeanMaxPPE (:default , [1.0 ], [0.2 ], [3.456 ])
32
+ ppe2 = MeanMaxPPE (:other , [1.0 ], [0.2 ], [3.456 ], ZonedDateTime (2014 , 5 , 30 , 21 , tz " UTC-4" ))
33
+ map (v -> addPPE! (dfg, getLabel (v), deepcopy (ppe1)), verts)
34
+ map (v -> addPPE! (dfg, getLabel (v), deepcopy (ppe2)), verts)
36
35
37
36
# call update to set it on cloud
38
- updateVariable! (dfg, verts[1 ])
39
- updateVariable! (dfg, verts[2 ])
37
+ updateVariable! .(dfg, verts)
40
38
41
- facts = map (n -> addFactor! (dfg, [verts[n], verts[n+ 1 ]], LinearConditional (Normal (50.0 ,2.0 ))), 1 : (numNodes- 1 ))
42
39
43
- # FIXME a lot of these makes test fail
44
- # facts[4].solverData.solveInProgress = 1
45
- # facts[4].solverData.multihypo = [1, 0.1, 0.9]
46
- # facts[4].solverData.eliminated = true
47
- # facts[4].solverData.potentialused = true
48
- # updateFactor!(dfg, facts[4])
40
+ facts = map (n -> addFactor! (dfg, [verts[n], verts[n+ 1 ]], LinearConditional (Normal (50.0 ,2.0 ))), 1 : (numNodes- 1 ))
41
+ map (f -> setSolvable! (f, Int (round (rand ()))), facts)
42
+ map (f -> f. solverData. multihypo = [1 , 0.1 , 0.9 ], facts)
43
+ map (f -> f. solverData. eliminated = rand () > 0.5 , facts)
44
+ map (f -> f. solverData. potentialused = rand () > 0.5 , facts)
45
+ updateFactor! .(dfg, facts)
46
+
49
47
# Save and load the graph to test.
50
48
saveDFG (filename, dfg)
51
49
52
- copyDfg = DistributedFactorGraphs. _getDuplicatedEmptyDFG (dfg)
53
- copyDf2 = DistributedFactorGraphs. _getDuplicatedEmptyDFG (dfg)
54
50
@info " Going to load $filename "
55
-
56
- @test_throws AssertionError loadDFG! (copyDf2 ," badfilename" )
51
+ copyDfg = DistributedFactorGraphs . _getDuplicatedEmptyDFG (dfg)
52
+ @test_throws AssertionError loadDFG! (DistributedFactorGraphs . _getDuplicatedEmptyDFG (dfg) ," badfilename" )
57
53
58
54
retDFG = loadDFG! (copyDfg, filename)
59
55
@@ -63,19 +59,39 @@ using Test
63
59
@test getVariable (dfg, var) == getVariable (retDFG, var)
64
60
end
65
61
for fact in lsf (dfg)
66
- @test getFactor (dfg, fact) == getFactor (retDFG, fact)
62
+ @test compareFactor (getFactor (dfg, fact),
63
+ getFactor (retDFG, fact),
64
+ skip= [
65
+ :hypotheses , :certainhypo , :multihypo , # Multihypo
66
+ :eliminated ,
67
+ :timezone , :zone , # Timezones
68
+ :potentialused ])
67
69
end
68
-
69
- if typeof (dfg) <: CloudGraphsDFG
70
- @warn " TODO: BigData still is being setup in CloudGraphs. Fix here! "
71
- else
72
- @test_broken length ( getDataEntries ( getVariable (retDFG, :x1 ))) == 1
73
- @test_broken typeof ( getDataEntry ( getVariable (retDFG, :x1 ), :testing )) == BlobStoreEntry
74
- @test_broken length ( getDataEntries ( getVariable (retDFG, :x2 ))) == 1
75
- @test_broken typeof ( getDataEntry ( getVariable (retDFG, :x2 ), :testing2 )) == BlobStoreEntry
70
+
71
+ # Check data entries
72
+ for v in ls (dfg)
73
+ @test getDataEntries ( getVariable (dfg, v)) == getDataEntries ( getVariable (retDFG, v))
74
+ @test issetequal ( listPPEs (dfg, v), listPPEs (retDFG, v))
75
+ for ppe in listPPEs (dfg, v)
76
+ @test getPPE (dfg, v, ppe) == getPPE (retDFG, v, ppe)
77
+ end
76
78
end
77
-
79
+
78
80
# test the duplicate order #581
79
81
saveDFG (dfg, filename)
80
82
end
81
83
end
84
+
85
+ @testset " FileDFG Regression Tests" begin
86
+ @info " If any of these tests fail, we have breaking changes"
87
+ for file in readdir (joinpath (@__DIR__ , " data" ))
88
+ loadFile = joinpath (@__DIR__ , " data" , file)
89
+ global dfg
90
+ dfgCopy = DistributedFactorGraphs. _getDuplicatedEmptyDFG (dfg)
91
+ retDFG = loadDFG! (dfgCopy, loadFile)
92
+ # It should have failed if there were any issues.
93
+ # Trivial check as well
94
+ @test issetequal (ls (retDFG), [:x1 , :x2 , :x3 , :x4 , :x5 ])
95
+ @test issetequal (lsf (retDFG), [:x3x4f1 , :x4x5f1 , :x1x2f1 , :x2x3f1 ])
96
+ end
97
+ end
0 commit comments