Skip to content

Commit

Permalink
A possible way to do VariableNodeData{T<:InferenceVariable} depreciation
Browse files Browse the repository at this point in the history
  • Loading branch information
Affie committed Oct 14, 2019
1 parent cd799c9 commit dcd97da
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions src/entities/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct SingletonInferenceVariable <: InferenceVariable end
"""
$(TYPEDEF)
"""
mutable struct VariableNodeData #TODO v0.5.0 {T<:InferenceVariable}
mutable struct VariableNodeData{T<:InferenceVariable}
val::Array{Float64,2}
bw::Array{Float64,2}
BayesNetOutVertIDs::Array{Symbol,1}
Expand All @@ -14,7 +14,7 @@ mutable struct VariableNodeData #TODO v0.5.0 {T<:InferenceVariable}
eliminated::Bool
BayesNetVertID::Symbol # Union{Nothing, }
separator::Array{Symbol,1}
softtype::InferenceVariable #TODO v0.5.0 T
softtype::T
initialized::Bool
inferdim::Float64
ismargin::Bool
Expand All @@ -24,7 +24,20 @@ mutable struct VariableNodeData #TODO v0.5.0 {T<:InferenceVariable}
# A valid, packable default constructor is needed.

end
VariableNodeData() = VariableNodeData(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], SingletonInferenceVariable(), false, 0.0, false, false)

VariableNodeData(params...) = VariableNodeData{InferenceVariable}(params...)

function VariableNodeData()
st = stacktrace()
@warn "VariableNodeData() is depreciated please use VariableNodeData{T}() or VariableNodeData(softtype::T) where T <: InferenceVariable\n$st"
VariableNodeData{InferenceVariable}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], SingletonInferenceVariable(), false, 0.0, false, false)
end

VariableNodeData{T}() where {T <:InferenceVariable} =
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], T(), false, 0.0, false, false)

VariableNodeData(softtype::T) where T <: InferenceVariable =
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], softtype, false, 0.0, false, false)

"""
$(TYPEDEF)
Expand Down Expand Up @@ -94,7 +107,7 @@ mutable struct DFGVariable <: AbstractDFGVariable
timestamp::DateTime
tags::Vector{Symbol}
estimateDict::Dict{Symbol, Dict{Symbol, <: AbstractVariableEstimate}}
solverDataDict::Dict{Symbol, VariableNodeData}
solverDataDict::Dict{Symbol, VariableNodeData} #TODO v0.5.0 Dict{Symbol, VariableNodeData{<:InferenceVariable}}

This comment has been minimized.

Copy link
@dehann

dehann Oct 14, 2019

Member

that is a abstract type using references

smallData::Dict{String, String}
bigData::Dict{Symbol, AbstractBigDataEntry}
ready::Int
Expand All @@ -106,11 +119,29 @@ end
$SIGNATURES
DFGVariable constructors.
"""
DFGVariable(label::Symbol, _internalId::Int64) =
DFGVariable(label, now(), Symbol[], Dict{Symbol, Dict{Symbol, VariableEstimate}}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)

DFGVariable(label::Symbol) =
DFGVariable(label, now(), Symbol[], Dict{Symbol, VariableEstimate}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, 0)
function DFGVariable(label::Symbol, _internalId::Int64 = 0) #where {T <:InferenceVariable}
st = stacktrace()
@warn "DFGVariable(label::Symbol, _internalId::Int64 = 0) is depreciated please use DFGVariable(label::Symbol, softtype::T, _internalId::Int64 = 0) where T <: InferenceVariable\n$st"
T = InferenceVariable
DFGVariable(label, now(), Symbol[],
Dict{Symbol, Dict{Symbol, VariableEstimate}}(),
Dict{Symbol, VariableNodeData{T}}(:default => VariableNodeData()),
Dict{String, String}(),
Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
end
DFGVariable(label::Symbol, softtype::T, _internalId::Int64 = 0) where {T <: InferenceVariable} =
DFGVariable(label, now(), Symbol[],
Dict{Symbol, Dict{Symbol, VariableEstimate}}(),
Dict{Symbol, VariableNodeData{T}}(:default => VariableNodeData{T}()),
Dict{String, String}(),
Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)

# DFGVariable(label::Symbol, _internalId::Int64) =
# DFGVariable(label, now(), Symbol[], Dict{Symbol, Dict{Symbol, VariableEstimate}}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, _internalId)
#
# DFGVariable(label::Symbol) =
# DFGVariable(label, now(), Symbol[], Dict{Symbol, VariableEstimate}(), Dict{Symbol, VariableNodeData}(:default => VariableNodeData()), Dict{String, String}(), Dict{Symbol,AbstractBigDataEntry}(), 0, 0, 0)
#

# Accessors
label(v::DFGVariable) = v.label
Expand Down

0 comments on commit dcd97da

Please sign in to comment.