Skip to content

Commit e4185ec

Browse files
authored
Merge pull request #440 from JuliaRobotics/maint/20Q2/gfnd#274part2
Remove deprecated fncargvID and remove unused frommodule.
2 parents 6f83a4b + a0224a9 commit e4185ec

File tree

10 files changed

+64
-55
lines changed

10 files changed

+64
-55
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export addData!, fetchData, fetchDataEntryElement
176176
# Factors
177177
##------------------------------------------------------------------------------
178178
# Factor Data
179-
export GenericFunctionNodeData
179+
export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData
180180
export InferenceType, PackedInferenceType, FunctorInferenceType, FactorOperationalMemory
181181
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize
182182

src/entities/DFGFactor.jl

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,49 @@ Notes
3030
3131
Designing (WIP)
3232
- T <: Union{FactorOperationalMemory, PackedInferenceType}
33-
# in IIF.CCW{T <: DFG.InferenceType}
34-
# in IIF.FunctorPairwiseMinimize <: InferenceType # DFG whatever, something, we'll figure it out
35-
# in Main/User, SomeFactor <: FunctorPairwiseMinimize
33+
- in IIF.CCW{T <: DFG.InferenceType}
34+
- in IIF.FunctorPairwiseMinimize <: InferenceType # DFG whatever, something, we'll figure it out
35+
- in Main/User, SomeFactor <: FunctorPairwiseMinimize
3636
"""
37-
mutable struct GenericFunctionNodeData{T<:Union{PackedInferenceType, FunctorInferenceType, FactorOperationalMemory}, S<:Union{Symbol, AbstractString}}
38-
fncargvID::Vector{Symbol}
37+
mutable struct GenericFunctionNodeData{T<:Union{PackedInferenceType, FunctorInferenceType, FactorOperationalMemory}}
3938
eliminated::Bool
4039
potentialused::Bool
41-
edgeIDs::Array{Int,1}
42-
frommodule::S # JT TODO remove frommodule, not used at all as far as i can tell
40+
edgeIDs::Vector{Int}
4341
fnc::T
4442
multihypo::Vector{Float64} # likely to moved when GenericWrapParam is refactored
4543
certainhypo::Vector{Int}
4644
solveInProgress::Int
47-
GenericFunctionNodeData{T, S}() where {T, S} = new{T,S}()
48-
GenericFunctionNodeData{T, S}(x1, x2, x3, x4, x5::S, x6::T, multihypo::Vector{<:Real}=Float64[], certainhypo::Vector{Int}=Int[], x9::Int=0) where {T, S} = new{T,S}(x1, x2, x3, x4, x5, x6, multihypo, certainhypo, x9)
49-
GenericFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, multihypo::Vector{<:Real}=Float64[], certainhypo::Vector{Int}=Int[], x9::Int=0) where {T, S} = new{T,S}(x1, x2, x3, x4, x5, x6, multihypo, certainhypo, x9)
50-
# GenericFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, x7::String) where {T, S} = new{T,S}(x1, x2, x3, x4, x5, x6, x7)
5145
end
5246

5347
## Constructors
5448

49+
GenericFunctionNodeData{T}() where T =
50+
GenericFunctionNodeData{T}(false, false, Int[], T(), Float64[], Int[], 0)
51+
52+
function GenericFunctionNodeData(eliminated,
53+
potentialused,
54+
edgeIDs,
55+
fnc,
56+
multihypo=Float64[],
57+
certainhypo=Int[])
58+
return GenericFunctionNodeData(eliminated, potentialused, edgeIDs, fnc, multihypo, certainhypo, 0)
59+
end
60+
61+
5562
##------------------------------------------------------------------------------
5663
## PackedFunctionNodeData and FunctionNodeData
5764

58-
# Simply for convenience - don't export, TODO Its used in IIF so maybe it should be exported
59-
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T, <: AbstractString}
60-
PackedFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where {T <: PackedInferenceType, S <: AbstractString} = GenericFunctionNodeData(x1, x2, x3, x4, x5, x6, multihypo, certainhypo, x9)
61-
const FunctionNodeData{T} = GenericFunctionNodeData{T, Symbol}
62-
FunctionNodeData(x1, x2, x3, x4, x5::Symbol, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where {T <: Union{FunctorInferenceType, FactorOperationalMemory}}= GenericFunctionNodeData{T, Symbol}(x1, x2, x3, x4, x5, x6, multihypo, certainhypo, x9)
65+
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T} where T <: PackedInferenceType
66+
PackedFunctionNodeData(args...) = PackedFunctionNodeData{typeof(args[4])}(args...)
67+
68+
const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{FunctorInferenceType, FactorOperationalMemory}
69+
FunctionNodeData(args...) = FunctionNodeData{typeof(args[4])}(args...)
70+
71+
72+
# PackedFunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: PackedInferenceType =
73+
# GenericFunctionNodeData{T}(x2, x3, x4, x6, multihypo, certainhypo, x9)
74+
# FunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: Union{FunctorInferenceType, FactorOperationalMemory} =
75+
# GenericFunctionNodeData{T}(x2, x3, x4, x6, multihypo, certainhypo, x9)
6376

6477
##==============================================================================
6578
## Factors
@@ -81,7 +94,7 @@ Complete factor structure for a DistributedFactorGraph factor.
8194
Fields:
8295
$(TYPEDFIELDS)
8396
"""
84-
mutable struct DFGFactor{T, S} <: AbstractDFGFactor
97+
mutable struct DFGFactor{T} <: AbstractDFGFactor
8598
"""Factor label, e.g. :x1f1.
8699
Accessor: [`getLabel`](@ref)"""
87100
label::Symbol
@@ -93,7 +106,7 @@ mutable struct DFGFactor{T, S} <: AbstractDFGFactor
93106
tags::Set{Symbol}
94107
"""Solver data.
95108
Accessors: [`getSolverData`](@ref), [`setSolverData!`](@ref)"""
96-
solverData::GenericFunctionNodeData{T, S}
109+
solverData::GenericFunctionNodeData{T}
97110
"""Solvable flag for the factor.
98111
Accessors: [`getSolvable`](@ref), [`setSolvable!`](@ref)
99112
TODO: Switch to `DFGNodeParams`"""
@@ -115,18 +128,18 @@ $(SIGNATURES)
115128
116129
Construct a DFG factor given a label.
117130
"""
118-
DFGFactor{T, S}(label::Symbol, internalId::Int64=0, timestamp::DateTime=now()) where {T, S} =
119-
DFGFactor(label, timestamp, Set{Symbol}(), GenericFunctionNodeData{T, S}(), 1, DFGNodeParams(1, internalId), Symbol[])
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[])
120133

121134

122135
DFGFactor(label::Symbol,
123136
variableOrderSymbols::Vector{Symbol},
124-
data::GenericFunctionNodeData{T, S};
137+
data::GenericFunctionNodeData{T};
125138
tags::Set{Symbol}=Set{Symbol}(),
126139
timestamp::DateTime=now(),
127140
solvable::Int=1,
128-
_internalId::Int64=0) where {T, S} =
129-
DFGFactor{T,S}(label,timestamp,tags,data,solvable,DFGNodeParams(solvable, _internalId),variableOrderSymbols)
141+
_internalId::Int64=0) where {T} =
142+
DFGFactor{T}(label,timestamp,tags,data,solvable,DFGNodeParams(solvable, _internalId),variableOrderSymbols)
130143

131144

132145

src/services/CompareUtils.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,12 @@ end
210210

211211

212212
# Compare FunctionNodeData
213-
function compare(a::GenericFunctionNodeData{T1,S},b::GenericFunctionNodeData{T2,S}) where {T1, T2, S}
213+
function compare(a::GenericFunctionNodeData{T1},b::GenericFunctionNodeData{T2}) where {T1, T2}
214214
# TODO -- beef up this comparison to include the gwp
215215
TP = true
216216
TP = TP && a.eliminated == b.eliminated
217217
TP = TP && a.potentialused == b.potentialused
218218
TP = TP && a.edgeIDs == b.edgeIDs
219-
TP = TP && a.frommodule == b.frommodule
220219
# TP = TP && typeof(a.fnc) == typeof(b.fnc)
221220
return TP
222221
end

src/services/Serialization.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function packFactor(dfg::G, f::DFGFactor)::Dict{String, Any} where G <: Abstract
119119
end
120120

121121

122-
function decodePackedType(::Type{T}, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where {T<:FactorOperationalMemory, PT}
122+
function decodePackedType(::Type{T}, packeddata::GenericFunctionNodeData{PT}) where {T<:FactorOperationalMemory, PT}
123123
# usrtyp = convert(FunctorInferenceType, packeddata.fnc)
124124
# Also look at parentmodule
125125
usrtyp = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
@@ -142,7 +142,7 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
142142
packed = nothing
143143
fullFactorData = nothing
144144
try
145-
packed = JSON2.read(data, GenericFunctionNodeData{packtype,String})
145+
packed = JSON2.read(data, GenericFunctionNodeData{packtype})
146146
decodeType = getFactorOperationalMemoryType(dfg)
147147
fullFactorData = decodePackedType(decodeType, packed)
148148
catch ex
@@ -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}(Symbol(label), 0, timestamp)
162+
factor = DFGFactor{typeof(fullFactorData.fnc)}(Symbol(label), 0, timestamp)
163163

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

test/DataStoreTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dfg = LightDFG{NoSolverParams}()
88
struct TestInferenceVariable1 <: InferenceVariable end
99
v1 = DFGVariable(:a, TestInferenceVariable1())
1010
v2 = DFGVariable(:b, TestInferenceVariable1())
11-
f1 = DFGFactor{TestFunctorInferenceType1, Symbol}(:f1)
11+
f1 = DFGFactor{TestFunctorInferenceType1}(:f1)
1212
#add tags for filters
1313
union!(v1.tags, [:VARIABLE, :POSE])
1414
union!(v2.tags, [:VARIABLE, :LANDMARK])

test/compareTests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ v2.solvable = 0
4242
@test !(DFGVariable(:x1, TestSofttype1()) == DFGVariable(:x1, TestSofttype2()))
4343

4444
# GenericFunctionNodeData
45-
gfnd1 = GenericFunctionNodeData([:a,:b], true, true, [1,2], :symbol, TestFunctorInferenceType1())
45+
gfnd1 = GenericFunctionNodeData(true, true, [1,2], TestFunctorInferenceType1())
4646
gfnd2 = deepcopy(gfnd1)
47-
gfnd3 = GenericFunctionNodeData([:a,:b], true, true, [1,2], :symbol, TestFunctorInferenceType2())
47+
gfnd3 = GenericFunctionNodeData(true, true, [1,2], TestFunctorInferenceType2())
4848

4949
@test gfnd1 == gfnd2
5050
@test !(gfnd1 == gfnd3)
@@ -72,9 +72,9 @@ vnd2.val[1] = 0.1
7272
@test !compare(vnd1, vnd2)
7373
@test !compare(vnd1, vnd3)
7474

75-
gfnd1 = GenericFunctionNodeData([:a,:b], true, true, [1,2], :symbol, TestFunctorInferenceType1())
75+
gfnd1 = GenericFunctionNodeData(true, true, [1,2], TestFunctorInferenceType1())
7676
gfnd2 = deepcopy(gfnd1)
77-
gfnd3 = GenericFunctionNodeData([:a,:b], true, true, [1,2], :symbol, PackedTestFunctorInferenceType1())
77+
gfnd3 = GenericFunctionNodeData(true, true, [1,2], PackedTestFunctorInferenceType1())
7878

7979
@test compare(gfnd1, gfnd2)
8080
@test_broken !(compare(gfnd1, gfnd3))

test/interfaceTests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ end
6262
fg = testDFGAPI()
6363
addVariable!(fg, DFGVariable(:a, TestSofttype1()))
6464
addVariable!(fg, DFGVariable(:b, TestSofttype1()))
65-
addFactor!(fg, DFGFactor(:abf1, [:a,:b], GenericFunctionNodeData{TestFunctorInferenceType1, Symbol}()))
65+
addFactor!(fg, DFGFactor(:abf1, [:a,:b], GenericFunctionNodeData{TestFunctorInferenceType1}()))
6666
addVariable!(fg, DFGVariable(:orphan, TestSofttype1(), solvable = 0))
6767

6868
AdjacencyMatricesTestBlock(fg)
@@ -101,7 +101,7 @@ end
101101
addVariable!(fg, DFGVariable(:a, TestSofttype1()))
102102
addVariable!(fg, DFGVariable(:b, TestSofttype1()))
103103
addVariable!(fg, DFGVariable(:c, TestSofttype1()))
104-
addFactor!(fg, DFGFactor(:f1, [:a,:b,:c], GenericFunctionNodeData{TestFunctorInferenceType1, Symbol}()))
104+
addFactor!(fg, DFGFactor(:f1, [:a,:b,:c], GenericFunctionNodeData{TestFunctorInferenceType1}()))
105105

106106
# fgcopy = testDFGAPI()
107107
# DFG._copyIntoGraph!(fg, fgcopy, union(ls(fg), lsf(fg)))

test/needsahomeTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct TestInferenceVariable2 <: InferenceVariable end
1010
# Build a graph
1111
v1 = DFGVariable(:a, TestInferenceVariable1())
1212
v2 = DFGVariable(:b, TestInferenceVariable1())
13-
f1 = DFGFactor{TestFunctorInferenceType1, Symbol}(:f1)
13+
f1 = DFGFactor{TestFunctorInferenceType1}(:f1)
1414
addVariable!(dfg, v1)
1515
addVariable!(dfg, v2)
1616
addFactor!(dfg, [v1, v2], f1)

test/plottingTest.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ numNodes = 10
1010
dfg = GraphsDFG{NoSolverParams}()
1111
verts = map(n -> DFGVariable(Symbol("x$n"), TestInferenceVariable1()), 1:numNodes)
1212
map(v -> addVariable!(dfg, v), verts)
13-
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor{TestFunctorInferenceType1, Symbol}(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
13+
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor{TestFunctorInferenceType1}(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
1414

1515
# Using GraphPlot plotting
1616
plot = dfgplot(dfg)

test/testBlocks.jl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ end
5959
struct TestCCW{T} <: FactorOperationalMemory where {T<:FunctorInferenceType}
6060
usrfnc!::T
6161
end
62+
63+
TestCCW{T}() where T = TestCCW(T())
64+
6265
Base.:(==)(a::TestCCW, b::TestCCW) = a.usrfnc! == b.usrfnc!
6366

6467

@@ -71,11 +74,9 @@ getFactorOperationalMemoryType(par::NoSolverParams) = TestCCW
7174
function Base.convert(::Type{DFG.FunctionNodeData{TestCCW{F}}},
7275
d::DFG.PackedFunctionNodeData{<:PackedInferenceType}) where F<:FunctorInferenceType
7376

74-
return DFG.FunctionNodeData(d.fncargvID,
75-
d.eliminated,
77+
return DFG.FunctionNodeData(d.eliminated,
7678
d.potentialused,
7779
d.edgeIDs,
78-
Symbol(d.frommodule),
7980
TestCCW(convert(F, d.fnc)),
8081
d.multihypo,
8182
d.certainhypo,
@@ -84,11 +85,9 @@ end
8485

8586
function Base.convert(::Type{DFG.PackedFunctionNodeData{P}}, d::DFG.FunctionNodeData{<:FactorOperationalMemory}) where P <: PackedInferenceType
8687
# mhstr = packmultihypo(d.fnc) # this is where certainhypo error occurs
87-
return DFG.PackedFunctionNodeData(d.fncargvID,
88-
d.eliminated,
88+
return DFG.PackedFunctionNodeData(d.eliminated,
8989
d.potentialused,
9090
d.edgeIDs,
91-
string(d.frommodule),
9291
convert(P, d.fnc.usrfnc!),
9392
d.multihypo,
9493
d.certainhypo,
@@ -310,14 +309,14 @@ function DFGFactorSCA()
310309
f1_tags = Set([:FACTOR])
311310
testTimestamp = now()
312311

313-
gfnd_prior = GenericFunctionNodeData(Symbol[], false, false, Int[], :DistributedFactorGraphs, TestCCW(TestFunctorSingleton()))
312+
gfnd_prior = GenericFunctionNodeData(false, false, Int[], TestCCW(TestFunctorSingleton()))
314313

315-
gfnd = GenericFunctionNodeData(Symbol[], false, false, Int[], :DistributedFactorGraphs, TestCCW(TestFunctorInferenceType1()))
314+
gfnd = GenericFunctionNodeData(false, false, Int[], TestCCW(TestFunctorInferenceType1()))
316315

317-
f1 = DFGFactor{TestCCW{TestFunctorInferenceType1}, Symbol}(f1_lbl)
316+
f1 = DFGFactor{TestCCW{TestFunctorInferenceType1}}(f1_lbl)
318317
f1 = DFGFactor(f1_lbl, [:a,:b], gfnd, tags = f1_tags, solvable=0)
319318

320-
f2 = DFGFactor{TestCCW{TestFunctorInferenceType1}, Symbol}(:bcf1)
319+
f2 = DFGFactor{TestCCW{TestFunctorInferenceType1}}(:bcf1)
321320
#TODO add tests for mutating vos in updateFactor and orphan related checks.
322321
# we should perhaps prevent an empty vos
323322
f2._variableOrderSymbols = [:b, :c]
@@ -367,11 +366,9 @@ function DFGFactorSCA()
367366
f0 = DFGFactor(:af1, [:a], gfnd_prior, tags = Set([:PRIOR]))
368367

369368
#fill in undefined fields
370-
f2.solverData.certainhypo = Int[]
371-
f2.solverData.fncargvID = Symbol[]
372-
f2.solverData.frommodule = :DistributedFactorGraphs
373-
f2.solverData.multihypo = Float64[]
374-
f2.solverData.edgeIDs = Int64[]
369+
# f2.solverData.certainhypo = Int[]
370+
# f2.solverData.multihypo = Float64[]
371+
# f2.solverData.edgeIDs = Int64[]
375372

376373
return (f0=f0, f1=f1, f2=f2)
377374
end
@@ -1012,7 +1009,7 @@ function connectivityTestGraph(::Type{T}; VARTYPE=DFGVariable, FACTYPE=DFGFactor
10121009
setSolvable!(dfg, :x8, 0)
10131010
setSolvable!(dfg, :x9, 0)
10141011

1015-
gfnd = GenericFunctionNodeData(Symbol[], false, false, Int[], :DistributedFactorGraphs, TestCCW(TestFunctorInferenceType1()))
1012+
gfnd = GenericFunctionNodeData(false, false, Int[], TestCCW(TestFunctorInferenceType1()))
10161013
f_tags = Set([:FACTOR])
10171014
# f1 = DFGFactor(f1_lbl, [:a,:b], gfnd, tags = f_tags)
10181015

@@ -1202,7 +1199,7 @@ function ProducingDotFiles(testDFGAPI,
12021199
v2 = VARTYPE(:b, VariableNodeData{TestSofttype1}())
12031200
end
12041201
if f1 == nothing
1205-
f1 = (FACTYPE==DFGFactor) ? DFGFactor{TestFunctorInferenceType1, Symbol}(:abf1) : FACTYPE(:abf1)
1202+
f1 = (FACTYPE==DFGFactor) ? DFGFactor{TestFunctorInferenceType1}(:abf1) : FACTYPE(:abf1)
12061203
end
12071204

12081205
addVariable!(dotdfg, v1)

0 commit comments

Comments
 (0)