Skip to content

Commit 20b7678

Browse files
committed
fix tests for val::Vector{P}
1 parent 4c60969 commit 20b7678

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

src/entities/DFGVariable.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ end
300300
$SIGNATURES
301301
The default DFGVariable constructor.
302302
"""
303-
function DFGVariable(label::Symbol, variableType::T;
303+
function DFGVariable(label::Symbol, variableType::Type{T};
304304
timestamp::Union{DateTime,ZonedDateTime}=now(localzone()),
305305
nstime::Nanosecond = Nanosecond(0),
306306
tags::Set{Symbol}=Set{Symbol}(),
@@ -309,14 +309,20 @@ function DFGVariable(label::Symbol, variableType::T;
309309
smallData::Dict{Symbol, SmallDataTypes}=Dict{Symbol, SmallDataTypes}(),
310310
dataDict::Dict{Symbol, AbstractDataEntry}=Dict{Symbol,AbstractDataEntry}(),
311311
solvable::Int=1) where {T <: InferenceVariable, P}
312-
312+
#
313313
if timestamp isa DateTime
314314
DFGVariable{T}(label, ZonedDateTime(timestamp, localzone()), nstime, tags, estimateDict, solverDataDict, smallData, dataDict, Ref(solvable))
315315
else
316316
DFGVariable{T}(label, timestamp, nstime, tags, estimateDict, solverDataDict, smallData, dataDict, Ref(solvable))
317317
end
318318
end
319319

320+
DFGVariable(label::Symbol,
321+
variableType::T;
322+
solverDataDict::Dict{Symbol, VariableNodeData{T,P}}=Dict{Symbol, VariableNodeData{T,getPointType(T)}}(),
323+
kw...) where {T <: InferenceVariable, P} = DFGVariable(label, T; solverDataDict=solverDataDict, kw...)
324+
#
325+
320326
function DFGVariable(label::Symbol,
321327
solverData::VariableNodeData{T};
322328
timestamp::Union{DateTime,ZonedDateTime}=now(localzone()),

src/services/CustomPrinting.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function printVariable( io::IO, vert::DFGVariable;
9494
println(ioc)
9595
end
9696
end
97+
nothing
9798
end
9899

99100
printFactor(vert::DFGFactor; kwargs...) = printFactor(stdout::IO, vert; kwargs...)
@@ -150,6 +151,7 @@ function printFactor( io::IO, vert::DFGFactor;
150151
println(ioc)
151152
end
152153
end
154+
nothing
153155
end
154156

155157

src/services/Serialization.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,28 @@ function unpackVariable(dfg::G,
160160

161161
variableType = getTypeFromSerializationModule(variableTypeString)
162162
isnothing(variableType) && error("Cannot deserialize variableType '$variableTypeString' in variable '$label'")
163+
pointType = getPointType(variableType)
163164

164165
if unpackSolverData
165166
packed = JSON2.read(packedProps["solverDataDict"], Dict{String, PackedVariableNodeData})
166-
solverData = Dict(Symbol.(keys(packed)) .=> map(p -> unpackVariableNodeData(dfg, p), values(packed)))
167+
solverData = Dict{Symbol, VariableNodeData{variableType, pointType}}(Symbol.(keys(packed)) .=> map(p -> unpackVariableNodeData(dfg, p), values(packed)))
167168
else
168-
solverData = Dict{Symbol, VariableNodeData}()
169+
solverData = Dict{Symbol, VariableNodeData{variableType, pointType}}()
169170
end
170171
# Rebuild DFGVariable using the first solver variableType in solverData
171-
variable = DFGVariable{variableType}(Symbol(packedProps["label"]), timestamp, nstime, Set(tags), ppeDict, solverData, smallData, Dict{Symbol,AbstractDataEntry}(), Ref(packedProps["solvable"]))
172+
# @info "dbg Serialization 171" variableType Symbol(packedProps["label"]) timestamp nstime ppeDict solverData smallData Dict{Symbol,AbstractDataEntry}() Ref(packedProps["solvable"])
173+
# variable = DFGVariable{variableType}(Symbol(packedProps["label"]), timestamp, nstime, Set(tags), ppeDict, solverData, smallData, Dict{Symbol,AbstractDataEntry}(), Ref(packedProps["solvable"]))
174+
variable = DFGVariable( Symbol(packedProps["label"]),
175+
variableType,
176+
timestamp=timestamp,
177+
nstime=nstime,
178+
tags=Set{Symbol}(tags),
179+
estimateDict=ppeDict,
180+
solverDataDict=solverData,
181+
smallData=smallData,
182+
dataDict=Dict{Symbol,AbstractDataEntry}(),
183+
solvable=packedProps["solvable"] )
184+
#
172185

173186
# Now rehydrate complete DataEntry type.
174187
if unpackBigData

test/fileDFGTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using TimeZones
1111
dfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
1212

1313
if typeof(dfg) <: CloudGraphsDFG
14-
@warn "TEST: Nuking all data for user '$(dfg.userId)', robot '$(dfg.robotId)'!"
14+
@warn "TEST: Removing all data for user '$(dfg.userId)', robot '$(dfg.robotId)'!"
1515
clearRobot!!(dfg)
1616
# Need to recreate this, otherwise there is going to be an issue when creating the nodes.
1717
createDfgSessionIfNotExist(dfg)

test/iifInterfaceTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
global dfg,v1,v2,f1
22

33
if typeof(dfg) <: CloudGraphsDFG
4-
@warn "TEST: Nuking all data for user '$(dfg.userId)'!"
4+
@warn "TEST: Removing all data for user '$(dfg.userId)'!"
55
clearUser!!(dfg)
66
createDfgSessionIfNotExist(dfg)
77
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if get(ENV, "DO_CGDFG_TESTS", "") == "true"
3939
LightDFG,
4040
CloudGraphsDFG,
4141
]
42-
@warn "TEST: Nuking all data for user 'testUserId'!"
42+
@warn "TEST: Removing all data for user 'testUserId'!"
4343
clearUser!!(CloudGraphsDFG(userId="testUserId"))
4444

4545
else

0 commit comments

Comments
 (0)