Skip to content

Commit c12d78a

Browse files
authored
Merge pull request #450 from JuliaRobotics/maint/20Q2/reminternalId
Remove _internalId
2 parents f88fc36 + c355b2f commit c12d78a

File tree

13 files changed

+30
-72
lines changed

13 files changed

+30
-72
lines changed

src/Deprecated.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
include("../attic/GraphsDFG/GraphsDFG.jl")
1111
@reexport using .GraphsDFGs
1212

13+
@deprecate getInternalId(args...) error("getInternalId is no longer in use")
1314

1415
@deprecate loadDFG(source::String, iifModule::Module, dest::AbstractDFG) loadDFG!(dest, source)
1516

@@ -20,8 +21,6 @@ include("../attic/GraphsDFG/GraphsDFG.jl")
2021
Base.getproperty(x::DFGFactor,f::Symbol) = begin
2122
if f == :solvable
2223
getfield(x,:_dfgNodeParams).solvable
23-
elseif f == :_internalId
24-
getfield(x,:_dfgNodeParams)._internalId
2524
else
2625
getfield(x,f)
2726
end
@@ -31,8 +30,6 @@ Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
3130
if f == :solvable
3231
setfield!(x,f,val)
3332
getfield(x,:_dfgNodeParams).solvable = val
34-
elseif f == :_internalId
35-
getfield(x,:_dfgNodeParams)._internalId = val
3633
else
3734
setfield!(x,f,val)
3835
end
@@ -41,8 +38,6 @@ end
4138
Base.getproperty(x::DFGVariable,f::Symbol) = begin
4239
if f == :solvable
4340
getfield(x,:_dfgNodeParams).solvable
44-
elseif f == :_internalId
45-
getfield(x,:_dfgNodeParams)._internalId
4641
else
4742
getfield(x,f)
4843
end
@@ -51,8 +46,6 @@ end
5146
Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
5247
if f == :solvable
5348
getfield(x,:_dfgNodeParams).solvable = val
54-
elseif f == :_internalId
55-
getfield(x,:_dfgNodeParams)._internalId = val
5649
else
5750
setfield!(x,f,val)
5851
end

src/LightDFG/services/LightDFG.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ function addVariable!(dfg::LightDFG{<:AbstractParams, V, <:AbstractDFGFactor}, v
2727
error("Variable '$(variable.label)' already exists in the factor graph")
2828
end
2929

30-
#NOTE Internal ID always set to zero as it is not needed?
31-
# variable._internalId = 0
32-
3330
FactorGraphs.addVariable!(dfg.g, variable) || return false
3431

3532
# Track insertion

src/entities/AbstractDFG.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ The common node parameters for variables and factors.
2626
"""
2727
mutable struct DFGNodeParams
2828
solvable::Int
29-
_internalId::Int64
30-
DFGNodeParams(s1=0,s2=0) = new(s1,s2)
3129
end
3230

3331
"""

src/entities/DFGFactor.jl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,22 @@ end
122122
##------------------------------------------------------------------------------
123123
## Constructors
124124

125-
#TODO _internalId?
126125
"""
127126
$(SIGNATURES)
128127
129128
Construct a DFG factor given a label.
130129
"""
131-
DFGFactor{T}(label::Symbol, internalId::Int64=0, timestamp::DateTime=now()) where {T} =
132-
DFGFactor(label, timestamp, Set{Symbol}(), GenericFunctionNodeData{T}(), 1, DFGNodeParams(1, internalId), Symbol[])
130+
DFGFactor{T}(label::Symbol, timestamp::DateTime=now()) where {T} =
131+
DFGFactor(label, timestamp, Set{Symbol}(), GenericFunctionNodeData{T}(), 1, DFGNodeParams(1), Symbol[])
133132

134133

135134
DFGFactor(label::Symbol,
136135
variableOrderSymbols::Vector{Symbol},
137136
data::GenericFunctionNodeData{T};
138137
tags::Set{Symbol}=Set{Symbol}(),
139138
timestamp::DateTime=now(),
140-
solvable::Int=1,
141-
_internalId::Int64=0) where {T} =
142-
DFGFactor{T}(label,timestamp,tags,data,solvable,DFGNodeParams(solvable, _internalId),variableOrderSymbols)
139+
solvable::Int=1) where {T} =
140+
DFGFactor{T}(label,timestamp,tags,data,solvable,DFGNodeParams(solvable),variableOrderSymbols)
143141

144142

145143

@@ -165,8 +163,6 @@ struct DFGFactorSummary <: AbstractDFGFactor
165163
"""Factor tags, e.g [:FACTOR].
166164
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
167165
tags::Set{Symbol}
168-
"""Internal ID used by some of the DFG drivers. We don't suggest using this outside of DFG."""
169-
_internalId::Int64
170166
"""Internal cache of the ordering of the neighbor variables. Rather use getNeighbors to get the list as this is an internal value.
171167
Accessors: [`getVariableOrder`](@ref)"""
172168
_variableOrderSymbols::Vector{Symbol}
@@ -214,7 +210,7 @@ const FactorDataLevel2 = Union{DFGFactor}
214210
##==============================================================================
215211

216212
DFGFactorSummary(f::DFGFactor) =
217-
DFGFactorSummary(f.label, f.timestamp, deepcopy(f.tags), f._dfgNodeParams._internalId, deepcopy(f._variableOrderSymbols))
213+
DFGFactorSummary(f.label, f.timestamp, deepcopy(f.tags), deepcopy(f._variableOrderSymbols))
218214

219215
SkeletonDFGFactor(f::FactorDataLevel1) =
220216
SkeletonDFGFactor(f.label, deepcopy(f.tags), deepcopy(f._variableOrderSymbols))

src/entities/DFGVariable.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@ DFGVariable(label::Symbol, softtype::T;
219219
solverDataDict::Dict{Symbol, VariableNodeData{T}}=Dict{Symbol, VariableNodeData{T}}(),
220220
smallData::Dict{String, String}=Dict{String, String}(),
221221
bigData::Dict{Symbol, AbstractBigDataEntry}=Dict{Symbol,AbstractBigDataEntry}(),
222-
solvable::Int=1,
223-
_internalId::Int64=0) where {T <: InferenceVariable} =
224-
DFGVariable{T}(label, timestamp, tags, estimateDict, solverDataDict, smallData, bigData, DFGNodeParams(solvable, _internalId))
222+
solvable::Int=1) where {T <: InferenceVariable} =
223+
DFGVariable{T}(label, timestamp, tags, estimateDict, solverDataDict, smallData, bigData, DFGNodeParams(solvable))
225224

226225

227226
DFGVariable(label::Symbol,
@@ -231,15 +230,14 @@ DFGVariable(label::Symbol,
231230
estimateDict::Dict{Symbol, <: AbstractPointParametricEst}=Dict{Symbol, MeanMaxPPE}(),
232231
smallData::Dict{String, String}=Dict{String, String}(),
233232
bigData::Dict{Symbol, AbstractBigDataEntry}=Dict{Symbol,AbstractBigDataEntry}(),
234-
solvable::Int=1,
235-
_internalId::Int64=0) where {T <: InferenceVariable} =
236-
DFGVariable{T}(label, timestamp, tags, estimateDict, Dict{Symbol, VariableNodeData{T}}(:default=>solverData), smallData, bigData, DFGNodeParams(solvable, _internalId))
233+
solvable::Int=1) where {T <: InferenceVariable} =
234+
DFGVariable{T}(label, timestamp, tags, estimateDict, Dict{Symbol, VariableNodeData{T}}(:default=>solverData), smallData, bigData, DFGNodeParams(solvable))
237235

238236
##------------------------------------------------------------------------------
239237
function Base.copy(o::DFGVariable)::DFGVariable
240238
return DFGVariable(o.label, getSofttype(o)(), tags=copy(o.tags), estimateDict=copy(o.estimateDict),
241239
solverDataDict=copy(o.solverDataDict), smallData=copy(o.smallData),
242-
bigData=copy(o.bigData), solvable=getSolvable(o), _internalId=getInternalId(o))
240+
bigData=copy(o.bigData), solvable=getSolvable(o))
243241
end
244242

245243
##------------------------------------------------------------------------------
@@ -273,8 +271,6 @@ struct DFGVariableSummary <: AbstractDFGVariable
273271
"""Dictionary of large data associated with this variable.
274272
Accessors: [`addBigDataEntry!`](@ref), [`getBigDataEntry`](@ref), [`updateBigDataEntry!`](@ref), and [`deleteBigDataEntry!`](@ref)"""
275273
bigData::Dict{Symbol, AbstractBigDataEntry}
276-
"""Internal ID used by some of the DFG drivers. We don't suggest using this outside of DFG."""
277-
_internalId::Int64
278274
end
279275

280276
##------------------------------------------------------------------------------
@@ -313,7 +309,7 @@ const VariableDataLevel2 = Union{DFGVariable}
313309
##==============================================================================
314310

315311
DFGVariableSummary(v::DFGVariable) =
316-
DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.ppeDict), Symbol(typeof(getSofttype(v))), v.bigData, v._internalId)
312+
DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.ppeDict), Symbol(typeof(getSofttype(v))), v.bigData)
317313

318314
SkeletonDFGVariable(v::VariableDataLevel1) =
319315
SkeletonDFGVariable(v.label, deepcopy(v.tags))

src/services/CommonAccessors.jl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,6 @@ end
7272

7373

7474

75-
##------------------------------------------------------------------------------
76-
## _internalId
77-
##------------------------------------------------------------------------------
78-
79-
"""
80-
$SIGNATURES
81-
82-
Return the internal ID for DFGNode.
83-
"""
84-
getInternalId(v::DataLevel2) = v._dfgNodeParams._internalId
85-
86-
getInternalId(v::Union{DFGVariableSummary, DFGFactorSummary}) = v._internalId
87-
88-
8975
##------------------------------------------------------------------------------
9076
## solvable
9177
##------------------------------------------------------------------------------

src/services/CompareUtils.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const GeneratedCompareUnion = Union{MeanMaxPPE, VariableNodeData, DFGNodeParams,
2424
DFGFactor, DFGFactorSummary, SkeletonDFGFactor}
2525

2626
@generated function ==(x::T, y::T) where T <: GeneratedCompareUnion
27-
ignored = [:_internalId]
27+
ignored = []
2828
mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), setdiff(fieldnames(x), ignored))
2929
end
3030

@@ -178,7 +178,7 @@ function compareVariable(A::DFGVariable,
178178
show::Bool=true,
179179
skipsamples::Bool=true )::Bool
180180
#
181-
skiplist = union([:attributes;:solverDataDict;:_internalId;:createdTimestamp;:lastUpdatedTimestamp],skip)
181+
skiplist = union([:attributes;:solverDataDict;:createdTimestamp;:lastUpdatedTimestamp],skip)
182182
TP = compareAll(A, B, skip=skiplist, show=show)
183183
varskiplist = skipsamples ? [:val; :bw] : Symbol[]
184184
skiplist = union([:softtype;],varskiplist)
@@ -189,7 +189,7 @@ function compareVariable(A::DFGVariable,
189189
Bd = getSolverData(B)
190190

191191
# TP = TP && compareAll(A.attributes, B.attributes, skip=[:softtype;], show=show)
192-
varskiplist = union(varskiplist, [:softtype;:_internalId])
192+
varskiplist = union(varskiplist, [:softtype])
193193
union!(varskiplist, skip)
194194
TP = TP && compareAll(Ad, Bd, skip=varskiplist, show=show)
195195
TP = TP && typeof(Ad.softtype) == typeof(Bd.softtype)
@@ -232,9 +232,9 @@ function compareFactor(A::DFGFactor,
232232
skipsamples::Bool=true,
233233
skipcompute::Bool=true )
234234
#
235-
TP = compareAll(A, B, skip=union([:attributes;:solverData;:_variableOrderSymbols;:_internalId],skip), show=show)
235+
TP = compareAll(A, B, skip=union([:attributes;:solverData;:_variableOrderSymbols],skip), show=show)
236236
# TP = TP & compareAll(A.attributes, B.attributes, skip=[:data;], show=show)
237-
TP = TP & compareAllSpecial(getSolverData(A), getSolverData(B), skip=union([:fnc;:_internalId], skip), show=show)
237+
TP = TP & compareAllSpecial(getSolverData(A), getSolverData(B), skip=union([:fnc], skip), show=show)
238238
TP = TP & compareAllSpecial(getSolverData(A).fnc, getSolverData(B).fnc, skip=union([:cpt;:measurement;:params;:varidx;:threadmodel], skip), show=show)
239239
TP = TP & (skipsamples || compareAll(getSolverData(A).fnc.measurement, getSolverData(B).fnc.measurement, show=show, skip=skip))
240240
TP = TP & (skipcompute || compareAll(getSolverData(A).fnc.params, getSolverData(B).fnc.params, show=show, skip=skip))

src/services/DFGFactor.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function setTimestamp(f::DFGFactor, ts::DateTime)
7373
end
7474

7575
function setTimestamp(f::DFGFactorSummary, ts::DateTime)
76-
return DFGFactorSummary(f.label, ts, f.tags, f._internalId, f._variableOrderSymbols)
76+
return DFGFactorSummary(f.label, ts, f.tags, f._variableOrderSymbols)
7777
end
7878

7979
setTimestamp!(f::FactorDataLevel1, ts::DateTime) = f.timestamp = ts
@@ -89,11 +89,10 @@ setTimestamp!(f::FactorDataLevel1, ts::DateTime) = f.timestamp = ts
8989
# isSolvable
9090

9191
##------------------------------------------------------------------------------
92-
## _dfgNodeParams [solvable _internalId]
92+
## _dfgNodeParams [solvable]
9393
##------------------------------------------------------------------------------
9494

9595
## COMMON
96-
# getInternalId
9796

9897

9998
##------------------------------------------------------------------------------

src/services/DFGVariable.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,20 @@ function setTimestamp(v::DFGVariableSummary, ts::DateTime; verbose::Bool=true)
173173
if verbose
174174
@warn "verbose=true: setTimestamp(::DFGVariableSummary,...) creates and returns a new immutable DFGVariable object (and didn't change a distributed factor graph object), make sure you are using the right pointers: getVariable(...). See setTimestamp!(...) and note suggested use is at addVariable!(..., [timestamp=...]). See DFG #315 for explanation."
175175
end
176-
return DFGVariableSummary(v.label, ts, v.tags, v.ppeDict, v.softtypename, v.bigData, v._internalId)
176+
return DFGVariableSummary(v.label, ts, v.tags, v.ppeDict, v.softtypename, v.bigData)
177177
end
178178

179179

180180
##------------------------------------------------------------------------------
181-
## _dfgNodeParams [_internalId, solvable]
181+
## _dfgNodeParams [solvable]
182182
##------------------------------------------------------------------------------
183183

184184
## COMMON: solvable
185185
# getSolvable
186186
# setSolvable!
187187
# isSolvable
188188

189-
## COMMON: _internalId
190-
# getInternalId
189+
## COMMON:
191190

192191
##------------------------------------------------------------------------------
193192
## ppeDict

src/services/Serialization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function unpackVariable(dfg::G, packedProps::Dict{String, Any})::DFGVariable whe
3737
solverData = Dict(Symbol.(keys(packed)) .=> map(p -> unpackVariableNodeData(dfg, p), values(packed)))
3838

3939
# Rebuild DFGVariable using the first solver softtype in solverData
40-
variable = DFGVariable{softtype}(Symbol(packedProps["label"]), timestamp, Set(tags), ppeDict, solverData, smallData, Dict{Symbol,AbstractBigDataEntry}(), DFGNodeParams(packedProps["solvable"],0))
40+
variable = DFGVariable{softtype}(Symbol(packedProps["label"]), timestamp, Set(tags), ppeDict, solverData, smallData, Dict{Symbol,AbstractBigDataEntry}(), DFGNodeParams(packedProps["solvable"]))
4141

4242
# Now rehydrate complete bigData type.
4343
for (k,bdeInter) in bigDataIntermed
@@ -159,7 +159,7 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
159159

160160
# Rebuild DFGFactor
161161
#TODO use constuctor to create factor
162-
factor = DFGFactor{typeof(fullFactorData.fnc)}(Symbol(label), 0, timestamp)
162+
factor = DFGFactor{typeof(fullFactorData.fnc)}(Symbol(label), timestamp)
163163

164164
union!(factor.tags, tags)
165165
# factor.data = fullFactorData #TODO

0 commit comments

Comments
 (0)