Skip to content

Commit 8d89bad

Browse files
authored
Merge pull request #804 from JuliaRobotics/21Q4/enh/vnd/infopercoord
(p)vnd.infoPerCoord::Vector{Float64} replaces .inferdim::Float64
2 parents 479fefc + 207abc5 commit 8d89bad

File tree

7 files changed

+184
-94
lines changed

7 files changed

+184
-94
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
2+
3+
# v0.16.0
4+
5+
- `{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)

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.15.3"
3+
version = "0.16.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/Deprecated.jl

Lines changed: 120 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -135,65 +135,141 @@ end
135135
## Deprecated in v0.11 Remove in the v0.12 cycle
136136
##==============================================================================
137137

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
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+
201+
202+
## ================================================================================
203+
## Deprecate before v0.17
204+
##=================================================================================
205+
206+
207+
Base.propertynames(x::VariableNodeData, private::Bool=false) = private ? (:inferdim, :infoPerCoord) : (:infoPerCoord,)
208+
209+
Base.getproperty(x::VariableNodeData,f::Symbol) = begin
210+
if f == :inferdim
211+
Base.depwarn("vnd.inferdim::Float64 is deprecated, use vnd.infoPerCoord::Vector{Float64} instead", :getproperty)
212+
# @warn "vnd.inferdim is deprecated, use .infoPerCoord instead"
213+
getfield(x, :infoPerCoord)
214+
else
215+
getfield(x,f)
152216
end
153-
getfield(x,f)
154217
end
155218

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
219+
function Base.setproperty!(x::VariableNodeData, f::Symbol, val::Real)
220+
_val = if f == :inferdim
221+
Base.depwarn("vnd.inferdim::Float64 is deprecated, use vnd.infoPerCoord::Vector{Float64} instead", :setproperty!)
222+
f = :infoPerCoord
223+
Float64[val;]
224+
else
225+
val
160226
end
161-
return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
227+
return setfield!(x, f, _val)
162228
end
163229

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
230+
function Base.setproperty!(x::VariableNodeData, f::Symbol, val::AbstractVector{<:Real})
231+
if f == :inferdim
232+
Base.depwarn("vnd.inferdim::Float64 is deprecated, use vnd.infoPerCoord::Vector{Float64} instead", :setproperty!)
233+
f = :infoPerCoord
169234
end
170-
getfield(x,f)
235+
return setfield!(x, f, val)
171236
end
172237

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
238+
#
239+
240+
Base.propertynames(x::PackedVariableNodeData, private::Bool=false) = private ? (:inferdim, :infoPerCoord) : (:infoPerCoord,)
241+
242+
Base.getproperty(x::PackedVariableNodeData,f::Symbol) = begin
243+
if f == :inferdim
244+
Base.depwarn("pvnd.inferdim::Float64 is deprecated, use vnd.infoPerCoord::Vector{Float64} instead", :getproperty)
245+
getfield(x, :infoPerCoord)
246+
else
247+
getfield(x,f)
177248
end
178-
return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
179249
end
180250

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
251+
function Base.setproperty!(x::PackedVariableNodeData, f::Symbol, val::Real)
252+
_val = if f == :inferdim
253+
Base.depwarn("pvnd.inferdim::Float64 is deprecated, use vnd.infoPerCoord::Vector{Float64} instead", :setproperty!)
254+
f = :infoPerCoord
255+
Float64[val;]
256+
else
257+
val
186258
end
187-
getfield(x,f)
259+
return setfield!(x, f, _val)
188260
end
189261

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
262+
function Base.setproperty!(x::PackedVariableNodeData, f::Symbol, val::AbstractVector{<:Real})
263+
if f == :inferdim
264+
Base.depwarn("pvnd.inferdim::Float64 is deprecated, use vnd.infoPerCoord::Vector{Float64} instead", :setproperty!)
265+
f = :infoPerCoord
194266
end
195-
return setfield!(x, f, convert(fieldtype(typeof(x), f), val))
267+
return setfield!(x, f, val)
196268
end
197269

198-
@deprecate getSofttype(args...) getVariableType(args...)
199-
@deprecate getSofttypename(args...) getVariableTypeName(args...)
270+
271+
@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...)
272+
273+
274+
275+
#

src/entities/DFGVariable.jl

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ mutable struct VariableNodeData{T<:InferenceVariable, P}
2929

3030
variableType::T
3131
initialized::Bool
32-
inferdim::Float64
32+
"""
33+
Replacing previous `inferdim::Float64`, new `.infoPerCoord::Vector{Float64}` will in
34+
future stores the amount information (per measurement dimension) captured in each
35+
coordinate dimension.
36+
"""
37+
infoPerCoord::Vector{Float64}
3338
ismargin::Bool
3439

3540
dontmargin::Bool
@@ -52,7 +57,7 @@ mutable struct VariableNodeData{T<:InferenceVariable, P}
5257
Symbol[],
5358
T(),
5459
false,
55-
0.0,
60+
Float64[0.0;],
5661
false,
5762
false,
5863
0,
@@ -67,55 +72,57 @@ end
6772

6873
VariableNodeData{T}(;solveKey::Symbol=:default ) where T <: InferenceVariable = VariableNodeData{T, getPointType(T)}(solveKey=solveKey)
6974

75+
# VariableNodeData( val::Vector{P},
76+
# bw::Matrix{<:Real},
77+
# BayesNetOutVertIDs::AbstractVector{Symbol},
78+
# dimIDs::AbstractVector{Int},
79+
# dims::Int,
80+
# eliminated::Bool,
81+
# BayesNetVertID::Symbol,
82+
# separator::Array{Symbol,1},
83+
# variableType::T,
84+
# initialized::Bool,
85+
# inferdim::Float64,
86+
# ismargin::Bool,
87+
# dontmargin::Bool,
88+
# solveInProgress::Int=0,
89+
# solvedCount::Int=0,
90+
# solveKey::Symbol=:default,
91+
# events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}()
92+
# ) where {T <: InferenceVariable, P} =
93+
# VariableNodeData{T,P}( val,bw,BayesNetOutVertIDs,dimIDs,dims,
94+
# eliminated,BayesNetVertID,separator,
95+
# variableType,initialized,inferdim,ismargin,
96+
# dontmargin, solveInProgress, solvedCount,
97+
# solveKey, events )
98+
#
99+
100+
101+
#
102+
70103
VariableNodeData( val::Vector{P},
71-
bw::Matrix{<:Real},
104+
bw::AbstractMatrix{<:Real},
72105
BayesNetOutVertIDs::AbstractVector{Symbol},
73106
dimIDs::AbstractVector{Int},
74107
dims::Int,
75108
eliminated::Bool,
76109
BayesNetVertID::Symbol,
77-
separator::Array{Symbol,1},
110+
separator::AbstractVector{Symbol},
78111
variableType::T,
79112
initialized::Bool,
80-
inferdim::Float64,
113+
ipc::AbstractVector{<:Real},
81114
ismargin::Bool,
82115
dontmargin::Bool,
83116
solveInProgress::Int=0,
84117
solvedCount::Int=0,
85118
solveKey::Symbol=:default,
86119
events::Dict{Symbol,Threads.Condition}=Dict{Symbol,Threads.Condition}()
87-
) where {T <: InferenceVariable, P} = VariableNodeData{T,P}(
88-
val,bw,BayesNetOutVertIDs,dimIDs,dims,
89-
eliminated,BayesNetVertID,separator,
90-
variableType,initialized,inferdim,ismargin,
91-
dontmargin, solveInProgress, solvedCount, solveKey, events )
92-
#
93-
94-
95-
#
96-
97-
VariableNodeData(val::Vector{P},
98-
bw::Matrix{<:Real},
99-
BayesNetOutVertIDs::AbstractVector{Symbol},
100-
dimIDs::AbstractVector{Int},
101-
dims::Int,
102-
eliminated::Bool,
103-
BayesNetVertID::Symbol,
104-
separator::AbstractVector{Symbol},
105-
variableType::T,
106-
initialized::Bool,
107-
inferdim::Float64,
108-
ismargin::Bool,
109-
dontmargin::Bool,
110-
solveInProgress::Int=0,
111-
solvedCount::Int=0,
112-
solveKey::Symbol=:default
113-
) where {T <: InferenceVariable, P} =
114-
VariableNodeData{T,P}( val,bw,BayesNetOutVertIDs,dimIDs,dims,
120+
) where {T <: InferenceVariable, P} =
121+
VariableNodeData{T,P}( val,bw,BayesNetOutVertIDs,dimIDs,dims,
115122
eliminated,BayesNetVertID,separator,
116-
variableType,initialized,inferdim,ismargin,
123+
variableType,initialized,ipc,ismargin,
117124
dontmargin, solveInProgress, solvedCount,
118-
solveKey )
125+
solveKey, events )
119126
#
120127

121128
function VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <: InferenceVariable
@@ -131,6 +138,8 @@ function VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <:
131138
false, 0, 0, solveKey )
132139
end
133140

141+
142+
134143
##==============================================================================
135144
## PackedVariableNodeData.jl
136145
##==============================================================================
@@ -156,7 +165,7 @@ mutable struct PackedVariableNodeData
156165
separator::Array{Symbol,1} # Int
157166
variableType::String
158167
initialized::Bool
159-
inferdim::Float64
168+
infoPerCoord::Vector{Float64}
160169
ismargin::Bool
161170
dontmargin::Bool
162171
solveInProgress::Int
@@ -175,7 +184,7 @@ mutable struct PackedVariableNodeData
175184
x10::Vector{Symbol}, # Int
176185
x11::String,
177186
x12::Bool,
178-
x13::Float64,
187+
x13::AbstractVector{<:Real},
179188
x14::Bool,
180189
x15::Bool,
181190
x16::Int,
@@ -194,7 +203,7 @@ mutable struct PackedVariableNodeData
194203
x10::Vector, # Int
195204
x11::String,
196205
x12::Bool,
197-
x13::Float64,
206+
x13::AbstractVector{<:Real},
198207
x14::Bool,
199208
x15::Bool,
200209
x16::Int,
@@ -204,7 +213,8 @@ mutable struct PackedVariableNodeData
204213
convert(Vector{Float64},x3),x4,
205214
convert(Vector{Symbol},x5),
206215
convert(Vector{Int},x6),x7,x8,x9,
207-
convert(Vector{Symbol},x10),x11,x12,x13,x14,x15,x16, solvedCount, solveKey)
216+
convert(Vector{Symbol},x10),x11,x12,
217+
x13,x14,x15,x16, solvedCount, solveKey )
208218
end
209219

210220
##==============================================================================

src/services/CompareUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function compare(a::VariableNodeData, b::VariableNodeData)
164164
a.BayesNetVertID != b.BayesNetVertID && @debug("BayesNetVertID is not equal")==nothing && return false
165165
a.separator != b.separator && @debug("separator is not equal")==nothing && return false
166166
a.initialized != b.initialized && @debug("initialized is not equal")==nothing && return false
167-
abs(a.inferdim - b.inferdim) > 1e-14 && @debug("inferdim is not equal")==nothing && return false
167+
!isapprox(a.infoPerCoord, b.infoPerCoord, atol=1e-13) && @debug("infoPerCoord is not equal")==nothing && return false
168168
a.ismargin != b.ismargin && @debug("ismargin is not equal")==nothing && return false
169169
a.dontmargin != b.dontmargin && @debug("dontmargin is not equal")==nothing && return false
170170
a.solveInProgress != b.solveInProgress && @debug("solveInProgress is not equal")==nothing && return false

src/services/Serialization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function packVariableNodeData(::G, d::VariableNodeData{T}) where {G <: AbstractD
243243
d.BayesNetVertID, d.separator,
244244
typeModuleName(d.variableType),
245245
d.initialized,
246-
d.inferdim,
246+
d.infoPerCoord,
247247
d.ismargin,
248248
d.dontmargin,
249249
d.solveInProgress,
@@ -276,7 +276,7 @@ function unpackVariableNodeData(dfg::G, d::PackedVariableNodeData) where G <: Ab
276276
#
277277
return VariableNodeData{T, getPointType(T)}(vals, BW, d.BayesNetOutVertIDs,
278278
d.dimIDs, d.dims, d.eliminated, d.BayesNetVertID, d.separator,
279-
T(), d.initialized, d.inferdim, d.ismargin, d.dontmargin,
279+
T(), d.initialized, d.infoPerCoord, d.ismargin, d.dontmargin,
280280
d.solveInProgress, d.solvedCount, d.solveKey,
281281
Dict{Symbol,Threads.Condition}() )
282282
end

0 commit comments

Comments
 (0)