Skip to content

Commit 447ddb4

Browse files
committed
Drop vector of covar in packed vnd for now
1 parent 467ec8e commit 447ddb4

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/entities/DFGVariable.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Fields:
2020
$(TYPEDFIELDS)
2121
"""
2222
Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P, N}
23-
"DEPRECATED remove in DFG v0.21"
23+
"DEPRECATED remove in DFG v0.22"
2424
variableType::T=T() #tricky deprecation, also change covar to using N and not variableType
2525
"""
2626
Globally unique identifier.
@@ -31,17 +31,17 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P, N}
3131
"""
3232
val::Vector{P} = Vector{P}()
3333
"""
34-
Common kernel bandwith parameter used with ManifoldKernelDensity, and as legacy also stores covariance until a dedicated field is created for parametric case.
34+
Common kernel bandwith parameter used with ManifoldKernelDensity, see field `covar` for the parametric covariance.
3535
"""
3636
bw::Matrix{Float64} = zeros(0,0)
3737
"Parametric (Gaussian) covariance."
3838
covar::Vector{SMatrix{N, N, Float64}} = SMatrix{getDimension(variableType), getDimension(variableType), Float64}[]
3939
BayesNetOutVertIDs::Vector{Symbol} = Symbol[]
4040
dimIDs::Vector{Int} = Int[] # TODO Likely deprecate
4141

42-
dims::Int = 0
42+
dims::Int = getDimension(variableType) #TODO should we deprecate in favor of N
4343
"""
44-
Flag used by junction (Bayes) tree construction algorith to know whether this variable has yet been included in the tree construction.
44+
Flag used by junction (Bayes) tree construction algorithm to know whether this variable has yet been included in the tree construction.
4545
"""
4646
eliminated::Bool = false
4747
BayesNetVertID::Symbol = :NOTHING # Union{Nothing, }
@@ -53,13 +53,13 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P, N}
5353
"""
5454
Stores the amount information (per measurement dimension) captured in each coordinate dimension.
5555
"""
56-
infoPerCoord::Vector{Float64} = Float64[0.0;]
56+
infoPerCoord::Vector{Float64} = zeros(getDimension(variableType))
5757
"""
5858
Should this variable solveKey be treated as marginalized in inference computations.
5959
"""
6060
ismargin::Bool = false
6161
"""
62-
Shoudl this variable solveKey always be kept fluid and not be automatically marginalized.
62+
Should this variable solveKey always be kept fluid and not be automatically marginalized.
6363
"""
6464
dontmargin::Bool = false
6565
"""
@@ -71,7 +71,7 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P, N}
7171
"""
7272
solvedCount::Int = 0
7373
"""
74-
solveKey identifier associated with thsi VariableNodeData object.
74+
solveKey identifier associated with this VariableNodeData object.
7575
"""
7676
solveKey::Symbol = :default
7777
"""
@@ -120,7 +120,7 @@ Base.@kwdef mutable struct PackedVariableNodeData
120120
solveInProgress::Int
121121
solvedCount::Int
122122
solveKey::Symbol
123-
covar::Vector{Vector{Float64}}
123+
covar::Vector{Float64}
124124
_version::String = string(_getDFGVersion())
125125
end
126126

src/services/Serialization.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ function packVariableNodeData(d::VariableNodeData{T}) where {T <: InferenceVaria
9292
zeros(1,0)
9393
end
9494
_val = castval[:]
95+
96+
length(d.covar) > 1 && @warn("Packing of more than one parametric covariance is NOT supported yet, only packing first.")
97+
9598
return PackedVariableNodeData(d.id, _val, size(castval,1),
9699
d.bw[:], size(d.bw,1),
97100
d.BayesNetOutVertIDs,
@@ -105,7 +108,7 @@ function packVariableNodeData(d::VariableNodeData{T}) where {T <: InferenceVaria
105108
d.solveInProgress,
106109
d.solvedCount,
107110
d.solveKey,
108-
vec.(d.covar),
111+
isempty(d.covar) ? Float64[] : vec(d.covar[1]),
109112
string(_getDFGVersion()))
110113
end
111114

@@ -132,11 +135,13 @@ function unpackVariableNodeData(d::PackedVariableNodeData)
132135
BW = reshape(d.vecbw,r4,c4)
133136

134137
#
135-
return VariableNodeData{T, getPointType(T), getDimension(T)}(;
138+
N = getDimension(T)
139+
return VariableNodeData{T, getPointType(T), N}(;
136140
id = d.id,
137141
val = vals,
138142
bw = BW,
139-
covar = d.covar,
143+
#TODO only one covar is currently supported in packed VND
144+
covar = isempty(d.covar) ? SMatrix{N, N, Float64}[] : [d.covar],
140145
BayesNetOutVertIDs = Symbol.(d.BayesNetOutVertIDs),
141146
dimIDs = d.dimIDs,
142147
dims = d.dims,

test/data/0_21_0.tar.gz

8.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)