Skip to content

Commit bad0893

Browse files
committed
Dehann's refactor of VariableNodeData constructor
1 parent fc5a503 commit bad0893

File tree

1 file changed

+72
-69
lines changed

1 file changed

+72
-69
lines changed

src/entities/DFGVariable.jl

Lines changed: 72 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17,99 +17,102 @@ Fields:
1717
$(TYPEDFIELDS)
1818
"""
1919
Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P}
20-
id::Union{UUID, Nothing} # If it's blank it doesn't exist in the DB.
20+
id::Union{UUID, Nothing} = nothing # If it's blank it doesn't exist in the DB.
2121
val::Vector{P}
22-
bw::Matrix{Float64}
23-
BayesNetOutVertIDs::Vector{Symbol}
24-
dimIDs::Vector{Int} # Likely deprecate
22+
bw::Matrix{Float64} = zeros(0,0)
23+
BayesNetOutVertIDs::Vector{Symbol} = Symbol[]
24+
dimIDs::Vector{Int} = Int[] # Likely deprecate
2525

26-
dims::Int
27-
eliminated::Bool
28-
BayesNetVertID::Symbol # Union{Nothing, }
29-
separator::Vector{Symbol}
26+
dims::Int = 0
27+
eliminated::Bool = false
28+
BayesNetVertID::Symbol = :NOTHING # Union{Nothing, }
29+
separator::Vector{Symbol} = Symbol[]
3030

3131
variableType::T
32-
initialized::Bool
32+
initialized::Bool = false
3333
"""
3434
Replacing previous `inferdim::Float64`, new `.infoPerCoord::Vector{Float64}` will in
3535
future stores the amount information (per measurement dimension) captured in each
3636
coordinate dimension.
3737
"""
38-
infoPerCoord::Vector{Float64}
39-
ismargin::Bool
38+
infoPerCoord::Vector{Float64} = Float64[0.0;]
39+
ismargin::Bool = false
4040

41-
dontmargin::Bool
42-
solveInProgress::Int
43-
solvedCount::Int
41+
dontmargin::Bool = false
42+
solveInProgress::Int = 0
43+
solvedCount::Int = 0
4444
solveKey::Symbol
4545

46-
events::Dict{Symbol,Threads.Condition}
47-
48-
VariableNodeData{T,P}(w...) where {T <:InferenceVariable, P} = new{T,P}(w...)
49-
VariableNodeData{T,P}(;solveKey::Symbol=:default ) where {T <:InferenceVariable, P} = new{T,P}(
50-
nothing,
51-
Vector{P}(),
52-
zeros(0,0),
53-
Symbol[],
54-
Int[],
55-
0,
56-
false,
57-
:NOTHING,
58-
Symbol[],
59-
T(),
60-
false,
61-
Float64[0.0;],
62-
false,
63-
false,
64-
0,
65-
0,
66-
solveKey,
67-
Dict{Symbol,Threads.Condition}() )
46+
events::Dict{Symbol,Threads.Condition} = Dict{Symbol,Threads.Condition}()
47+
48+
# VariableNodeData{T,P}(w...) where {T <:InferenceVariable, P} = new{T,P}(w...)
49+
# VariableNodeData{T,P}(;solveKey::Symbol=:default ) where {T <:InferenceVariable, P} = new{T,P}(
50+
# nothing,
51+
# Vector{P}(),
52+
# zeros(0,0),
53+
# Symbol[],
54+
# Int[],
55+
# 0,
56+
# false,
57+
# :NOTHING,
58+
# Symbol[],
59+
# T(),
60+
# false,
61+
# Float64[0.0;],
62+
# false,
63+
# false,
64+
# 0,
65+
# 0,
66+
# solveKey,
67+
# Dict{Symbol,Threads.Condition}() )
6868
#
6969
end
7070

71+
7172
##------------------------------------------------------------------------------
7273
## Constructors
7374

74-
VariableNodeData{T}(;solveKey::Symbol=:default ) where T <: InferenceVariable = VariableNodeData{T, getPointType(T)}(solveKey=solveKey)
75-
76-
VariableNodeData( val::Vector{P},
77-
bw::AbstractMatrix{<:Real},
78-
BayesNetOutVertIDs::AbstractVector{Symbol},
79-
dimIDs::AbstractVector{Int},
80-
dims::Int,
81-
eliminated::Bool,
82-
BayesNetVertID::Symbol,
83-
separator::AbstractVector{Symbol},
84-
variableType::T,
85-
initialized::Bool,
86-
ipc::AbstractVector{<:Real},
87-
ismargin::Bool,
88-
dontmargin::Bool,
89-
solveInProgress::Int=0,
90-
solvedCount::Int=0,
91-
solveKey::Symbol=:default,
92-
events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}();
93-
id::Union{UUID, Nothing}=nothing
94-
) where {T <: InferenceVariable, P} =
95-
VariableNodeData{T,P}( id, val,bw,BayesNetOutVertIDs,dimIDs,dims,
96-
eliminated,BayesNetVertID,separator,
97-
variableType,initialized,ipc,ismargin,
98-
dontmargin, solveInProgress, solvedCount,
99-
solveKey, events )
75+
VariableNodeData{T,P}(;solveKey::Symbol=:default) where {T <: InferenceVariable, P} = VariableNodeData(; val=Vector{P}(), variableType=T(), solveKey)
76+
VariableNodeData{T}(;solveKey::Symbol=:default ) where T <: InferenceVariable = VariableNodeData(; solveKey, variableType=T(), val=Vector{getPointType(T)}()) # {T, getPointType(T)}
77+
78+
# VariableNodeData( val::Vector{P},
79+
# bw::AbstractMatrix{<:Real},
80+
# BayesNetOutVertIDs::AbstractVector{Symbol},
81+
# dimIDs::AbstractVector{Int},
82+
# dims::Int,
83+
# eliminated::Bool,
84+
# BayesNetVertID::Symbol,
85+
# separator::AbstractVector{Symbol},
86+
# variableType::T,
87+
# initialized::Bool,
88+
# ipc::AbstractVector{<:Real},
89+
# ismargin::Bool,
90+
# dontmargin::Bool,
91+
# solveInProgress::Int=0,
92+
# solvedCount::Int=0,
93+
# solveKey::Symbol=:default,
94+
# events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}();
95+
# id::Union{UUID, Nothing}=nothing
96+
# ) where {T <: InferenceVariable, P} =
97+
# VariableNodeData{T,P}( id, val,bw,BayesNetOutVertIDs,dimIDs,dims,
98+
# eliminated,BayesNetVertID,separator,
99+
# variableType,initialized,ipc,ismargin,
100+
# dontmargin, solveInProgress, solvedCount,
101+
# solveKey, events )
100102
#
101103

102104
function VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <: InferenceVariable
103105
#
104106
# p0 = getPointIdentity(T)
105-
P0 = Vector{getPointType(T)}()
107+
val = Vector{getPointType(T)}()
106108
# P0[1] = p0
107-
BW = zeros(0,0)
108-
# BW[1] = zeros(getDimension(T))
109-
VariableNodeData( P0, BW, Symbol[], Int[],
110-
0, false, :NOTHING, Symbol[],
111-
variableType, false, [0.0], false,
112-
false, 0, 0, solveKey )
109+
bw = zeros(0,0)
110+
# bw[1] = zeros(getDimension(T))
111+
VariableNodeData(; val, bw, solveKey, variableType )
112+
# VariableNodeData( nothing, P0, BW, Symbol[], Int[],
113+
# 0, false, :NOTHING, Symbol[],
114+
# variableType, false, [0.0], false,
115+
# false, 0, 0, solveKey )
113116
end
114117

115118

0 commit comments

Comments
 (0)