-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterfaceTests.jl
230 lines (187 loc) · 6.52 KB
/
interfaceTests.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
if false
using Test
using GraphMakie
using DistributedFactorGraphs
using Pkg
using Dates
using UUIDs
using TimeZones
include("testBlocks.jl")
testDFGAPI = GraphsDFG
# Enable debug logging
using Logging
logger = SimpleLogger(stdout, Logging.Debug)
global_logger(logger)
# or
logger = ConsoleLogger(stdout, Logging.Debug)
global_logger(logger)
end
# DFG Accessors
@testset "DFG Structure and Accessors" begin
# Constructors
# Constructors to be implemented
global fg1 = DFGStructureAndAccessors(testDFGAPI)
end
# User, Robot, Session Data
@testset "User, Robot, Session Data" begin
GraphAgentMetadata!(fg1)
end
@testset "User, Robot, Session Blob Entries" begin
GraphAgentBlobEntries!(fg1)
end
# VariableCompute structure construction and accessors
@testset "DFG Variable" begin
global var1, var2, var3, v1_tags, vorphan
var1, var2, var3, vorphan, v1_tags = DFGVariableSCA()
end
# FactorCompute structure construction and accessors
@testset "DFG Factor" begin
global fac0, fac1, fac2 = DFGFactorSCA()
end
@testset "Variables and Factors CRUD and SET" begin
VariablesandFactorsCRUD_SET!(fg1, var1, var2, var3, fac0, fac1, fac2)
end
@testset "Custom Printing" begin
global var1, var2, var3, v1_tags, vorphan
iobuf = IOBuffer()
# for now just test the interface and a bit of output
@test printVariable(var1) === nothing
@test printFactor(fac1) === nothing
@test printVariable(iobuf, var1; skipfields = [:timestamp, :solver, :ppe, :nstime]) ===
nothing
# for julia v1.6
if DistributedFactorGraphs._getDFGVersion() < v"0.19"
@test String(take!(iobuf)) ==
"VariableCompute{TestVariableType1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}(:small=>\"data\")\ndataDict:\nDict{Symbol, DistributedFactorGraphs.BlobEntry}()\nsolvable:\n0\n"
else
@test String(take!(iobuf)) ==
"VariableCompute{TestVariableType1, Vector{Float64}, 1}\nid:\nnothing\nlabel:\n:a\ntags:\nSet([:VARIABLE, :POSE])\nsmallData:\nDict{Symbol, Union{Bool, Float64, Int64, Vector{Bool}, Vector{Float64}, Vector{Int64}, Vector{String}, String}}(:small=>\"data\")\ndataDict:\nDict{Symbol, BlobEntry}()\nsolvable:\n0\n"
end
@test printVariable(iobuf, var1; short = true) === nothing
varstr = String(take!(iobuf))
@test occursin(r"VariableCompute", varstr)
@test occursin(r"timestamp", varstr)
@test occursin(r"label", varstr)
@test occursin(r"bandwidths", varstr)
# == "VariableCompute{TestVariableType1}\nlabel: a\ntags: Set([:VARIABLE, :POSE])\nsize marginal samples: (1, 1)\nkde bandwidths: [0.0]\nNo PPEs\n"
@test printFactor(iobuf, fac1; skipfields = [:timestamp, :solver, :nstime]) === nothing
@test occursin(r"FactorCompute.*\nid:\nnothing\nlabel:\n:abf1", String(take!(iobuf)))
String(take!(iobuf)) ==
"FactorCompute{TestCCW{TestFunctorInferenceType1}}\nid:\nnothing\nlabel:\n:abf1\ntags:\nSet([:tag1, :tag2])\nsolvable:\n0\nsolvable:\n1\n_variableOrderSymbols:\n[:a, :b]\n"
@test printFactor(iobuf, fac1; short = true) === nothing
@show teststr = String(take!(iobuf))
@test occursin(r"FactorCompute", teststr)
@test occursin(r"label", teststr)
@test occursin(r"timestamp", teststr)
@test occursin(r"tags", teststr)
@test occursin(r"solvable", teststr)
# s = String(take!(iobuf))
@test show(var1) === nothing
@test show(fac1) === nothing
@test show(iobuf, MIME("text/plain"), var1) === nothing
isapprox(length(take!(iobuf)), 452; atol = 10)
@test show(iobuf, MIME("text/plain"), fac1) === nothing
isapprox(length(take!(iobuf)), 301; atol = 10)
@test printVariable(fg1, :a) === nothing
@test printFactor(fg1, :abf1) === nothing
@test printNode(fg1, :a) === nothing
@test printNode(fg1, :abf1) === nothing
show(stdout, MIME("application/prs.juno.inline"), var1) == var1
show(stdout, MIME("application/prs.juno.inline"), fac1) == fac1
end
@testset "tags" begin
tagsTestBlock!(fg1, var1, v1_tags)
end
@testset "Parametric Point Estimates" begin
PPETestBlock!(fg1, var1)
end
@testset "Variable Solver Data" begin
VSDTestBlock!(fg1, var1)
end
@testset "Metadata CRUD" begin
smallDataTestBlock!(fg1)
end
@testset "Data Entries and Blobs" begin
if typeof(fg1) <: InMemoryDFGTypes
DataEntriesTestBlock!(fg1, var2)
end
@testset "Data blob tests" begin
blobsStoresTestBlock!(fg1)
end
end
@testset "TODO Sorteer groep" begin
if typeof(fg1) <: InMemoryDFGTypes
testGroup!(fg1, var1, var2, fac0, fac1)
else
@test_skip testGroup!(fg1, var1, var2, fac0, fac1)
end
end
# order up to here is important, TODO maybe make independant
##
@testset "Adjacency Matrices" begin
fg = testDFGAPI(; userLabel = "[email protected]")
addVariable!(fg, var1)
setSolvable!(fg, :a, 1)
addVariable!(fg, var2)
addFactor!(fg, fac1)
addVariable!(fg, vorphan)
AdjacencyMatricesTestBlock(fg)
end
@testset "Getting Neighbors" begin
rand(1)
GettingNeighbors(testDFGAPI)
end
@testset "Building Subgraphs" begin
rand(2)
BuildingSubgraphs(testDFGAPI)
end
#TODO Summaries and Summary Graphs
@testset "Summaries and Summary Graphs" begin
rand(3)
Summaries(testDFGAPI)
end
@testset "Producing Dot Files" begin
rand(4)
if testDFGAPI <: InMemoryDFGTypes
ProducingDotFiles(testDFGAPI)
else
ProducingDotFiles(testDFGAPI, var1, var2, fac1)
end
end
@testset "Connectivity Test" begin
rand(5)
ConnectivityTest(testDFGAPI)
end
@testset "Copy Functions" begin
rand(6)
fg = testDFGAPI(; userLabel = "[email protected]")
addVariable!(fg, var1)
addVariable!(fg, var2)
addVariable!(fg, var3)
addFactor!(fg, fac1)
# fgcopy = testDFGAPI()
# DFG._copyIntoGraph!(fg, fgcopy, union(ls(fg), lsf(fg)))
# @test getVariableOrder(fg,:f1) == getVariableOrder(fgcopy,:f1)
#test copyGraph, deepcopyGraph[!]
fgcopy = testDFGAPI(; userLabel = "[email protected]")
DFG.deepcopyGraph!(fgcopy, fg)
@test getVariableOrder(fg, :abf1) == getVariableOrder(fgcopy, :abf1)
CopyFunctionsTest(testDFGAPI)
end
@testset "File Save Functions" begin
rand(7)
if testDFGAPI <: InMemoryDFGTypes
FileDFGTestBlock(testDFGAPI)
else
@test_skip FileDFGTestBlock(testDFGAPI)
end
end
#=
fg = fg1
v1 = var1
v2 = var2
v3 = var3
f0 = fac0
f1 = fac1
f2 = fac2
=#