Skip to content

Commit dcd97da

Browse files
committed
A possible way to do VariableNodeData{T<:InferenceVariable} depreciation
1 parent cd799c9 commit dcd97da

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

src/entities/DFGVariable.jl

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct SingletonInferenceVariable <: InferenceVariable end
55
"""
66
$(TYPEDEF)
77
"""
8-
mutable struct VariableNodeData #TODO v0.5.0 {T<:InferenceVariable}
8+
mutable struct VariableNodeData{T<:InferenceVariable}
99
val::Array{Float64,2}
1010
bw::Array{Float64,2}
1111
BayesNetOutVertIDs::Array{Symbol,1}
@@ -14,7 +14,7 @@ mutable struct VariableNodeData #TODO v0.5.0 {T<:InferenceVariable}
1414
eliminated::Bool
1515
BayesNetVertID::Symbol # Union{Nothing, }
1616
separator::Array{Symbol,1}
17-
softtype::InferenceVariable #TODO v0.5.0 T
17+
softtype::T
1818
initialized::Bool
1919
inferdim::Float64
2020
ismargin::Bool
@@ -24,7 +24,20 @@ mutable struct VariableNodeData #TODO v0.5.0 {T<:InferenceVariable}
2424
# A valid, packable default constructor is needed.
2525

2626
end
27-
VariableNodeData() = VariableNodeData(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], SingletonInferenceVariable(), false, 0.0, false, false)
27+
28+
VariableNodeData(params...) = VariableNodeData{InferenceVariable}(params...)
29+
30+
function VariableNodeData()
31+
st = stacktrace()
32+
@warn "VariableNodeData() is depreciated please use VariableNodeData{T}() or VariableNodeData(softtype::T) where T <: InferenceVariable\n$st"
33+
VariableNodeData{InferenceVariable}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], SingletonInferenceVariable(), false, 0.0, false, false)
34+
end
35+
36+
VariableNodeData{T}() where {T <:InferenceVariable} =
37+
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], T(), false, 0.0, false, false)
38+
39+
VariableNodeData(softtype::T) where T <: InferenceVariable =
40+
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], softtype, false, 0.0, false, false)
2841

2942
"""
3043
$(TYPEDEF)
@@ -94,7 +107,7 @@ mutable struct DFGVariable <: AbstractDFGVariable
94107
timestamp::DateTime
95108
tags::Vector{Symbol}
96109
estimateDict::Dict{Symbol, Dict{Symbol, <: AbstractVariableEstimate}}
97-
solverDataDict::Dict{Symbol, VariableNodeData}
110+
solverDataDict::Dict{Symbol, VariableNodeData} #TODO v0.5.0 Dict{Symbol, VariableNodeData{<:InferenceVariable}}
98111
smallData::Dict{String, String}
99112
bigData::Dict{Symbol, AbstractBigDataEntry}
100113
ready::Int
@@ -106,11 +119,29 @@ end
106119
$SIGNATURES
107120
DFGVariable constructors.
108121
"""
109-
DFGVariable(label::Symbol, _internalId::Int64) =
110-
DFGVariable(label, now(), Symbol[], Dict{Symbol, Dict{Symbol, VariableEstimate}}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
111-
112-
DFGVariable(label::Symbol) =
113-
DFGVariable(label, now(), Symbol[], Dict{Symbol, VariableEstimate}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, 0)
122+
function DFGVariable(label::Symbol, _internalId::Int64 = 0) #where {T <:InferenceVariable}
123+
st = stacktrace()
124+
@warn "DFGVariable(label::Symbol, _internalId::Int64 = 0) is depreciated please use DFGVariable(label::Symbol, softtype::T, _internalId::Int64 = 0) where T <: InferenceVariable\n$st"
125+
T = InferenceVariable
126+
DFGVariable(label, now(), Symbol[],
127+
Dict{Symbol, Dict{Symbol, VariableEstimate}}(),
128+
Dict{Symbol, VariableNodeData{T}}(:default => VariableNodeData()),
129+
Dict{String, String}(),
130+
Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
131+
end
132+
DFGVariable(label::Symbol, softtype::T, _internalId::Int64 = 0) where {T <: InferenceVariable} =
133+
DFGVariable(label, now(), Symbol[],
134+
Dict{Symbol, Dict{Symbol, VariableEstimate}}(),
135+
Dict{Symbol, VariableNodeData{T}}(:default => VariableNodeData{T}()),
136+
Dict{String, String}(),
137+
Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
138+
139+
# DFGVariable(label::Symbol, _internalId::Int64) =
140+
# DFGVariable(label, now(), Symbol[], Dict{Symbol, Dict{Symbol, VariableEstimate}}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
141+
#
142+
# DFGVariable(label::Symbol) =
143+
# DFGVariable(label, now(), Symbol[], Dict{Symbol, VariableEstimate}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, 0)
144+
#
114145

115146
# Accessors
116147
label(v::DFGVariable) = v.label

0 commit comments

Comments
 (0)