Skip to content

Commit 2419b53

Browse files
authored
Merge pull request #842 from JuliaRobotics/22Q1/maint/cleanup
cleanup AbstractFactor and initAll!, more
2 parents b9f40b9 + 1968443 commit 2419b53

File tree

10 files changed

+38
-95
lines changed

10 files changed

+38
-95
lines changed

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
22

3+
# v0.18.0
4+
5+
- Unpack of GenericFactorNodeData now get `dfg::AbstractDFG` and `varOrder::Vector{Symbol}`, deprecating previous use of `convert` without the graph context (#832).
6+
- Switch to GraphsDFG, deprecating archived LightGraphs.jl (#826).
7+
- Workaround: packed factor data `.fnc` encoded as base64 to avoid escape character problems (#834).
8+
- Towards distributions serialized via JSON, getting away from custom strings.
9+
310
# v0.16.0
411

512
- `{Packed}VariableNodeData.infoPerCoord::Vector{Float64}` replaces previous `.inferdim::Float64`. The change should have legacy support to help facilitate the transition. This datastore is likely to only become part of critical computations downstream in IncrementalInference.jl v0.26, even though the previous `.inferdim` data values are being populated there. (#804)

attic/DataStoreTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dfg = testDFGAPI{NoSolverParams}()
1919
# struct TestInferenceVariable1 <: InferenceVariable end
2020
# v1 = DFGVariable(:a, TestInferenceVariable1())
2121
# v2 = DFGVariable(:b, TestInferenceVariable1())
22-
# f1 = DFGFactor{TestFunctorInferenceType1}(:f1, [:a,:b]);
22+
# f1 = DFGFactor{TestAbstractFactor1}(:f1, [:a,:b]);
2323
# #add tags for filters
2424
# union!(v1.tags, [:VARIABLE, :POSE])
2525
# union!(v2.tags, [:VARIABLE, :LANDMARK])

src/Common.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ _getmodule(t::T) where T = T.name.module
44
_getname(t::T) where T = T.name.name
55

66

7-
convertPackedType(t::Union{T, Type{T}}) where {T <: FunctorInferenceType} = getfield(_getmodule(t), Symbol("Packed$(_getname(t))"))
8-
function convertStructType(::Type{PT}) where {PT <: PackedInferenceType}
7+
convertPackedType(t::Union{T, Type{T}}) where {T <: AbstractFactor} = getfield(_getmodule(t), Symbol("Packed$(_getname(t))"))
8+
function convertStructType(::Type{PT}) where {PT <: AbstractPackedFactor}
99
# see #668 for expanded reasoning. PT may be ::UnionAll if the type is of template type.
1010
ptt = PT isa DataType ? PT.name.name : PT
1111
moduleName = PT isa DataType ? PT.name.module : Main

src/Deprecated.jl

Lines changed: 12 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
## Deprecated in v0.9 Remove in the v0.10 cycle
66
##==============================================================================
77

8-
Base.promote_rule(::Type{DateTime}, ::Type{ZonedDateTime}) = DateTime
9-
function Base.convert(::Type{DateTime}, ts::ZonedDateTime)
10-
@warn "DFG now uses ZonedDateTime, temporary promoting and converting to DateTime local time"
11-
return DateTime(ts, Local)
12-
end
13-
148
@deprecate listSolvekeys(x...) listSolveKeys(x...)
159

1610
##==============================================================================
@@ -131,73 +125,6 @@ function updateVariableSolverData!(dfg::AbstractDFG,
131125
end
132126

133127

134-
##==============================================================================
135-
## Deprecated in v0.11 Remove in the v0.12 cycle
136-
##==============================================================================
137-
138-
# # @warn("BREAKING CHANGE coming to DistributedFactorGraphs v0.12: deprecating AbstractRelativeFactor, use AbstractRelativeRoots instead")
139-
# # @warn("BREAKING CHANGE coming to DistributedFactorGraphs v0.12: deprecating AbstractRelativeFactorMinimize, use AbstractRelativeMinimize instead")
140-
# # export AbstractRelativeFactor, AbstractRelativeFactorMinimize
141-
# const AbstractRelativeFactor = AbstractRelativeRoots
142-
# const AbstractRelativeFactorMinimize = AbstractRelativeMinimize
143-
144-
# ##-------------------------------------------------------------------------------
145-
# ## softtype -> variableType deprecation
146-
# ##-------------------------------------------------------------------------------
147-
148-
# function Base.getproperty(x::VariableNodeData,f::Symbol)
149-
# if f == :softtype
150-
# Base.depwarn("`VariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
151-
# f = :variableType
152-
# end
153-
# getfield(x,f)
154-
# end
155-
156-
# function Base.setproperty!(x::VariableNodeData, f::Symbol, val)
157-
# if f == :softtype
158-
# Base.depwarn("`VariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
159-
# f = :variableType
160-
# end
161-
# return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
162-
# end
163-
164-
165-
# function Base.getproperty(x::PackedVariableNodeData,f::Symbol)
166-
# if f == :softtype
167-
# Base.depwarn("`PackedVariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
168-
# f = :variableType
169-
# end
170-
# getfield(x,f)
171-
# end
172-
173-
# function Base.setproperty!(x::PackedVariableNodeData, f::Symbol, val)
174-
# if f == :softtype
175-
# Base.depwarn("`PackedVariableNodeData` field `softtype` is deprecated, use `variableType`", :getproperty)
176-
# f = :variableType
177-
# end
178-
# return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
179-
# end
180-
181-
182-
# function Base.getproperty(x::DFGVariableSummary,f::Symbol)
183-
# if f == :softtypename
184-
# Base.depwarn("`DFGVariableSummary` field `softtypename` is deprecated, use `variableTypeName`", :getproperty)
185-
# f = :variableTypeName
186-
# end
187-
# getfield(x,f)
188-
# end
189-
190-
# function Base.setproperty!(x::DFGVariableSummary, f::Symbol, val)
191-
# if f == :softtypename
192-
# Base.depwarn("`DFGVariableSummary` field `softtypename` is deprecated, use `variableTypeName`", :getproperty)
193-
# f = :variableTypeName
194-
# end
195-
# return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
196-
# end
197-
198-
# @deprecate getSofttype(args...) getVariableType(args...)
199-
# @deprecate getSofttypename(args...) getVariableTypeName(args...)
200-
201128

202129
## ================================================================================
203130
## Deprecate before v0.17
@@ -271,5 +198,17 @@ end
271198
@deprecate VariableNodeData(val::Vector,bw::AbstractMatrix{<:Real},BayesNetOutVertIDs::AbstractVector{Symbol},dimIDs::AbstractVector{Int},dims::Int,eliminated::Bool,BayesNetVertID::Symbol,separator::AbstractVector{Symbol},variableType,initialized::Bool,inferdim::Real,w...;kw...) VariableNodeData(val,bw,BayesNetOutVertIDs,dimIDs,dims,eliminated,BayesNetVertID,separator,variableType,initialized,Float64[inferdim;],w...;kw...)
272199

273200

201+
## ================================================================================
202+
## Deprecate before v0.19
203+
##=================================================================================
204+
205+
const FunctorInferenceType = AbstractFactor # will eventually deprecate
206+
const PackedInferenceType = AbstractPackedFactor # will eventually deprecate
207+
208+
Base.promote_rule(::Type{DateTime}, ::Type{ZonedDateTime}) = DateTime
209+
function Base.convert(::Type{DateTime}, ts::ZonedDateTime)
210+
@warn "DFG now uses ZonedDateTime, temporary promoting and converting to DateTime local time"
211+
return DateTime(ts, Local)
212+
end
274213

275214
#

src/entities/DFGFactor.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
abstract type AbstractFactor end
77
abstract type AbstractPackedFactor end
88

9-
const FunctorInferenceType = AbstractFactor # will eventually deprecate
10-
const PackedInferenceType = AbstractPackedFactor # will eventually deprecate
11-
129
abstract type AbstractPrior <: AbstractFactor end
1310
abstract type AbstractRelative <: AbstractFactor end
1411
abstract type AbstractRelativeRoots <: AbstractRelative end
@@ -18,7 +15,7 @@ abstract type AbstractManifoldMinimize <: AbstractRelative end # FIXME move here
1815
# NOTE DF, Convolution is IIF idea, but DFG should know about "FactorOperationalMemory"
1916
# DF, IIF.CommonConvWrapper <: FactorOperationalMemory #
2017
# NOTE was `<: Function` as unnecessary
21-
abstract type FactorOperationalMemory end # <: Function
18+
abstract type FactorOperationalMemory end
2219
# TODO to be removed from DFG,
2320
# we can add to IIF or have IIF.CommonConvWrapper <: FactorOperationalMemory directly
2421
# abstract type ConvolutionObject <: FactorOperationalMemory end
@@ -34,12 +31,12 @@ Notes
3431
- S::Symbol
3532
3633
Designing (WIP)
37-
- T <: Union{FactorOperationalMemory, PackedInferenceType}
38-
- in IIF.CCW{T <: DFG.FunctorInferenceType}
39-
- in DFG.AbstractRelativeMinimize <: FunctorInferenceType
34+
- T <: Union{FactorOperationalMemory, AbstractPackedFactor}
35+
- in IIF.CCW{T <: DFG.AbstractFactor}
36+
- in DFG.AbstractRelativeMinimize <: AbstractFactor
4037
- in Main.SomeFactor <: AbstractRelativeMinimize
4138
"""
42-
mutable struct GenericFunctionNodeData{T<:Union{<:PackedInferenceType, <:AbstractFactor, <:FactorOperationalMemory}}
39+
mutable struct GenericFunctionNodeData{T<:Union{<:AbstractPackedFactor, <:AbstractFactor, <:FactorOperationalMemory}}
4340
eliminated::Bool
4441
potentialused::Bool
4542
edgeIDs::Vector{Int}
@@ -85,9 +82,9 @@ const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{<:Abstra
8582
FunctionNodeData(args...) = FunctionNodeData{typeof(args[4])}(args...)
8683

8784

88-
# PackedFunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: PackedInferenceType =
85+
# PackedFunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: AbstractPackedFactor =
8986
# GenericFunctionNodeData{T}(x2, x3, x4, x6, multihypo, certainhypo, x9)
90-
# FunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: Union{FunctorInferenceType, FactorOperationalMemory} =
87+
# FunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: Union{AbstractFactor, FactorOperationalMemory} =
9188
# GenericFunctionNodeData{T}(x2, x3, x4, x6, multihypo, certainhypo, x9)
9289

9390
##==============================================================================

src/services/AbstractDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,15 @@ function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: InferenceVariable}
630630
end
631631

632632

633-
function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: FunctorInferenceType}
633+
function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactor}
634634
xx = getFactors(dfg)
635635
names = typeof.(getFactorType.(xx)) .|> nameof
636636
vxx = view(xx, names .== Symbol(T))
637637
map(x->x.label, vxx)
638638
end
639639

640640

641-
function lsf(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: FunctorInferenceType}
641+
function lsf(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactor}
642642
ls(dfg, T)
643643
end
644644

@@ -1104,7 +1104,7 @@ function isPathFactorsHomogeneous(dfg::AbstractDFG, from::Symbol, to::Symbol)
11041104
(length(utyp) == 1), utyp
11051105
end
11061106

1107-
function existsPathOfFactorsType(dfg::AbstractDFG, from::Symbol, to::Symbol, ftype::FunctorInferenceType)
1107+
function existsPathOfFactorsType(dfg::AbstractDFG, from::Symbol, to::Symbol, ftype::AbstractFactor)
11081108
error("WIP")
11091109
end
11101110

src/services/CompareUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ implement compare if needed.
1414

1515
==(a::FactorOperationalMemory, b::FactorOperationalMemory) = typeof(a) == typeof(b)
1616

17-
==(a::FunctorInferenceType, b::FunctorInferenceType) = typeof(a) == typeof(b)
17+
==(a::AbstractFactor, b::AbstractFactor) = typeof(a) == typeof(b)
1818

1919

2020
# Generate compares automatically for all in this union

test/attic/IIF4DoorsTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ addFactor!(fg,[:x5;:x6], LinearConditional( Normal(40.0,1.20)) )
5858
addVariable!(fg,:x7,ContinuousScalar, N=N)
5959
addFactor!(fg,[:x6;:x7], LinearConditional( Normal(60.0,2.0)) )
6060

61-
# ensureAllInitialized!(fg)
61+
# initAll!(fg)
6262

6363
mlc = MixturePrior(Normal.(doors[1,:], bws[1]), 0.25*ones(4))
6464

test/iifCompareTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ using Test
5050
@test compareFactorGraphs(fg, fg)
5151
@test !compareFactorGraphs(fg, fg2, skipsamples=false)
5252

53-
ensureAllInitialized!(fg2)
53+
initAll!(fg2)
5454

5555
@test compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:initialized;:inferdim;:ppeDict;:solvedCount])
5656
# fg2 has been solved, so it should fail on the estimate dictionary

test/testBlocks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct TestAbstractPrior <: AbstractPrior end
3434
struct TestAbstractRelativeFactor <: AbstractRelativeRoots end
3535
struct TestAbstractRelativeFactorMinimize <: AbstractRelativeMinimize end
3636

37-
struct PackedTestFunctorInferenceType1 <: PackedInferenceType
37+
struct PackedTestFunctorInferenceType1 <: AbstractPackedFactor
3838
s::String
3939
end
4040
PackedTestFunctorInferenceType1() = PackedTestFunctorInferenceType1("")
@@ -55,7 +55,7 @@ function Base.convert(::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInf
5555
end
5656

5757

58-
struct PackedTestAbstractPrior <: PackedInferenceType
58+
struct PackedTestAbstractPrior <: AbstractPackedFactor
5959
s::String
6060
end
6161
PackedTestAbstractPrior() = PackedTestAbstractPrior("")
@@ -119,7 +119,7 @@ end
119119
#test Specific definitions
120120
# struct TestInferenceVariable1 <: InferenceVariable end
121121
# struct TestInferenceVariable2 <: InferenceVariable end
122-
# struct TestFunctorInferenceType1 <: FunctorInferenceType end
122+
# struct TestFunctorInferenceType1 <: AbstractFactor end
123123

124124
# NOTE see note in AbstractDFG.jl setSolverParams!
125125
struct GeenSolverParams <: AbstractParams

0 commit comments

Comments
 (0)