Skip to content

Commit 20d2378

Browse files
committed
rename VariableState -> State, FactorSolverCache -> FactorCache
1 parent 64c17b5 commit 20d2378

17 files changed

Lines changed: 222 additions & 253 deletions

src/Common.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ sortDFG(vars::Vector{Symbol}; lt = natural_lt, kwargs...) = sort(vars; lt = lt,
8888
# label_contains(x::String) = contains(x)
8989
# label_startswith(x::String) = startswith(x)
9090
# label_endswith(x::String) = endswith(x)
91-
# type_eq(x::AbstractVariableStateType) = ==(x)
92-
# type_in(x::Vector{<:AbstractVariableStateType}) = in(x)
91+
# type_eq(x::AbstractStateType) = ==(x)
92+
# type_in(x::Vector{<:AbstractStateType}) = in(x)
9393
# type_contains(x::String) = contains(x)
9494
# type_startswith(x::String) = startswith(x)
9595
# type_endswith(x::String) = endswith(x)

src/Deprecated.jl

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const AbstractParams = AbstractDFGParams
1919
abstract type AbstractRelativeMinimize <: RelativeObservation end
2020
abstract type AbstractManifoldMinimize <: RelativeObservation end
2121

22-
const InferenceVariable = VariableStateType{Any}
22+
const InferenceVariable = StateType{Any}
2323
const InferenceType = AbstractPackedObservation
2424

2525
const PackedSamplableBelief = PackedBelief
@@ -29,29 +29,26 @@ export setSolverData!
2929
# $SIGNATURES
3030
# Set solver data structure stored in a variable.
3131
# """
32-
function setSolverData!(v::VariableCompute, data::VariableState, key::Symbol = :default)
32+
function setSolverData!(v::VariableCompute, data::State, key::Symbol = :default)
3333
Base.depwarn(
34-
"setSolverData!(v::VariableCompute, data::VariableState, key::Symbol = :default) is deprecated, use mergeVariableState! instead.",
34+
"setSolverData!(v::VariableCompute, data::State, key::Symbol = :default) is deprecated, use mergeState! instead.",
3535
:setSolverData!,
3636
)
37-
@assert key == data.solveKey "VariableState.solveKey=:$(data.solveKey) does not match requested :$(key)"
37+
@assert key == data.solveKey "State.solveKey=:$(data.solveKey) does not match requested :$(key)"
3838
return v.solverDataDict[key] = data
3939
end
4040

41-
@deprecate mergeVariableSolverData!(args...; kwargs...) mergeVariableState!(
42-
args...;
43-
kwargs...,
44-
)
41+
@deprecate mergeVariableSolverData!(args...; kwargs...) mergeState!(args...; kwargs...)
4542

4643
export mergeVariableData!, mergeGraphVariableData!
4744
function mergeVariableData!(args...)
4845
return error(
49-
"mergeVariableData! is obsolete, use mergeVariableState! for state, PPEs are obsolete",
46+
"mergeVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
5047
)
5148
end
5249
function mergeGraphVariableData!(args...)
5350
return error(
54-
"mergeGraphVariableData! is obsolete, use mergeVariableState! for state, PPEs are obsolete",
51+
"mergeGraphVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
5552
)
5653
end
5754

@@ -83,7 +80,7 @@ function lsWho(dfg::AbstractDFG, type::Symbol)
8380
end
8481

8582
# solvekey is deprecated and sync!/copyto! is the better verb.
86-
#TODO replace with syncVariableStates! or similar
83+
#TODO replace with syncStates! or similar
8784
# """
8885
# $SIGNATURES
8986
# Duplicate a `solveKey`` into a destination from a source.
@@ -102,8 +99,8 @@ function cloneSolveKey!(
10299
)
103100
#
104101
for x in labels
105-
sd = deepcopy(getVariableState(getVariable(src_dfg, x), src))
106-
copytoVariableState!(dest_dfg, x, dest, sd)
102+
sd = deepcopy(getState(getVariable(src_dfg, x), src))
103+
copytoState!(dest_dfg, x, dest, sd)
107104
end
108105

109106
return nothing
@@ -151,10 +148,7 @@ function listSolveKeys(
151148
filterSolveKeys::Union{Regex, Nothing} = nothing,
152149
skeys = Set{Symbol}(),
153150
)
154-
Base.depwarn(
155-
"listSolveKeys is deprecated, use listVariableStates instead.",
156-
:listSolveKeys,
157-
)
151+
Base.depwarn("listSolveKeys is deprecated, use listStates instead.", :listSolveKeys)
158152
#
159153
for ky in keys(getSolverDataDict(variable))
160154
push!(skeys, ky)
@@ -178,7 +172,7 @@ end
178172

179173
function listSolveKeys(
180174
dfg::AbstractDFG,
181-
filterVariables::Union{Type{<:VariableStateType}, Regex, Nothing} = nothing;
175+
filterVariables::Union{Type{<:StateType}, Regex, Nothing} = nothing;
182176
filterSolveKeys::Union{Regex, Nothing} = nothing,
183177
tags::Vector{Symbol} = Symbol[],
184178
solvable::Int = 0,
@@ -208,10 +202,10 @@ export AbstractPackedFactor
208202
const AbstractPackedFactor = AbstractPackedObservation
209203

210204
export FactorOperationalMemory
211-
const FactorOperationalMemory = FactorSolverCache
205+
const FactorOperationalMemory = FactorCache
212206

213207
export VariableNodeData
214-
const VariableNodeData = VariableState
208+
const VariableNodeData = State
215209

216210
@deprecate getNeighborhood(args...; kwargs...) listNeighborhood(args...; kwargs...)
217211
@deprecate addBlob!(store::AbstractBlobstore, blobId::UUID, data, ::String) addBlob!(
@@ -277,56 +271,47 @@ const VariableNodeData = VariableState
277271
)
278272
@deprecate mergeBlobEntries!(args...; kwargs...) mergeBlobentries!(args...; kwargs...)
279273

280-
@deprecate getVariableSolverData(args...; kwargs...) getVariableState(args...; kwargs...)
281-
@deprecate addVariableSolverData!(args...; kwargs...) addVariableState!(args...; kwargs...)
282-
@deprecate deleteVariableSolverData!(args...; kwargs...) deleteVariableState!(
283-
args...;
284-
kwargs...,
285-
)
286-
@deprecate listVariableSolverData(args...; kwargs...) listVariableStates(args...; kwargs...)
287-
@deprecate getVariableSolverDataAll(args...; kwargs...) getVariableStates(
288-
args...;
289-
kwargs...,
290-
)
274+
@deprecate getVariableSolverData(args...; kwargs...) getState(args...; kwargs...)
275+
@deprecate addVariableSolverData!(args...; kwargs...) addState!(args...; kwargs...)
276+
@deprecate deleteVariableSolverData!(args...; kwargs...) deleteState!(args...; kwargs...)
277+
@deprecate listVariableSolverData(args...; kwargs...) listStates(args...; kwargs...)
278+
@deprecate getVariableSolverDataAll(args...; kwargs...) getStates(args...; kwargs...)
291279

292-
@deprecate getSolverData(v::VariableCompute, solveKey::Symbol = :default) getVariableState(
280+
@deprecate getSolverData(v::VariableCompute, solveKey::Symbol = :default) getState(
293281
v,
294282
solveKey,
295283
)
296284

297-
@deprecate packVariableNodeData(args...; kwargs...) packVariableState(args...; kwargs...)
298-
@deprecate unpackVariableNodeData(args...; kwargs...) unpackVariableState(
299-
args...;
300-
kwargs...,
301-
)
285+
@deprecate packVariableNodeData(args...; kwargs...) packState(args...; kwargs...)
286+
@deprecate unpackVariableNodeData(args...; kwargs...) unpackState(args...; kwargs...)
302287

303288
export updateVariableSolverData!
304289

305290
#TODO possibly completely deprecated or not exported until update verb is standardized
306291
function updateVariableSolverData!(
307292
dfg::AbstractDFG,
308293
variablekey::Symbol,
309-
vnd::VariableState,
294+
vnd::State,
310295
useCopy::Bool = false,
311296
fields::Vector{Symbol} = Symbol[];
312297
warn_if_absent::Bool = true,
313298
)
314299
Base.depwarn(
315-
"updateVariableSolverData! is deprecated, use mergeVariableState! or copytoVariableState! instead",
300+
"updateVariableSolverData! is deprecated, use mergeState! or copytoState! instead",
316301
:updateVariableSolverData!,
317302
)
318303
#This is basically just setSolverData
319304
var = getVariable(dfg, variablekey)
320305
warn_if_absent &&
321306
!haskey(var.solverDataDict, vnd.solveKey) &&
322-
@warn "VariableState '$(vnd.solveKey)' does not exist, adding"
307+
@warn "State '$(vnd.solveKey)' does not exist, adding"
323308

324309
# for InMemoryDFGTypes do memory copy or repointing, for cloud this would be an different kind of update.
325310
usevnd = vnd # useCopy ? deepcopy(vnd) : vnd
326311
# should just one, or many pointers be updated?
327312
useExisting =
328313
haskey(var.solverDataDict, vnd.solveKey) &&
329-
isa(var.solverDataDict[vnd.solveKey], VariableState) &&
314+
isa(var.solverDataDict[vnd.solveKey], State) &&
330315
length(fields) != 0
331316
# @error useExisting vnd.solveKey
332317
if useExisting
@@ -353,7 +338,7 @@ end
353338
function updateVariableSolverData!(
354339
dfg::AbstractDFG,
355340
variablekey::Symbol,
356-
vnd::VariableState,
341+
vnd::State,
357342
solveKey::Symbol,
358343
useCopy::Bool = false,
359344
fields::Vector{Symbol} = Symbol[];
@@ -362,7 +347,7 @@ function updateVariableSolverData!(
362347
# TODO not very clean
363348
if vnd.solveKey != solveKey
364349
Base.depwarn(
365-
"updateVariableSolverData with solveKey is deprecated use copytoVariableState! instead.",
350+
"updateVariableSolverData with solveKey is deprecated use copytoState! instead.",
366351
:updateVariableSolverData!,
367352
)
368353
usevnd = useCopy ? deepcopy(vnd) : vnd
@@ -400,7 +385,7 @@ function updateVariableSolverData!(
400385
# toshow = listSolveKeys(sourceVariable) |> collect
401386
# @info "update DFGVar solveKey" solveKey vnd.solveKey
402387
# @show toshow
403-
@assert solveKey == vnd.solveKey "VariableState's solveKey=:$(vnd.solveKey) does not match requested :$solveKey"
388+
@assert solveKey == vnd.solveKey "State's solveKey=:$(vnd.solveKey) does not match requested :$solveKey"
404389
return updateVariableSolverData!(
405390
dfg,
406391
sourceVariable.label,
@@ -434,7 +419,7 @@ end
434419

435420
## factor refactor deprecations
436421
Base.@kwdef mutable struct GenericFunctionNodeData{
437-
T <: Union{<:AbstractPackedObservation, <:AbstractObservation, <:FactorSolverCache},
422+
T <: Union{<:AbstractPackedObservation, <:AbstractObservation, <:FactorCache},
438423
}
439424
eliminated::Bool = false
440425
potentialused::Bool = false
@@ -457,7 +442,7 @@ function FactorCompute(
457442
variableOrder::Union{Vector{Symbol}, Tuple};
458443
observation = getFactorType(solverData),
459444
state::FactorState = FactorState(),
460-
solvercache::Base.RefValue{<:FactorSolverCache} = Ref{FactorSolverCache}(),
445+
solvercache::Base.RefValue{<:FactorCache} = Ref{FactorCache}(),
461446
id::Union{UUID, Nothing} = nothing,
462447
smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(),
463448
)
@@ -512,7 +497,7 @@ function decodePackedType(
512497
varOrder::AbstractVector{Symbol},
513498
::Type{T},
514499
packeddata::GenericFunctionNodeData{PT},
515-
) where {T <: FactorSolverCache, PT}
500+
) where {T <: FactorCache, PT}
516501
error("decodePackedType is obsolete")
517502
#
518503
# TODO, to solve IIF 1424
@@ -552,9 +537,8 @@ function PackedFunctionNodeData(args...; kw...)
552537
return PackedFunctionNodeData{typeof(args[4])}(args...; kw...)
553538
end
554539

555-
const FunctionNodeData{T} = GenericFunctionNodeData{
556-
T,
557-
} where {T <: Union{<:AbstractObservation, <:FactorSolverCache}}
540+
const FunctionNodeData{T} =
541+
GenericFunctionNodeData{T} where {T <: Union{<:AbstractObservation, <:FactorCache}}
558542
FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw...)
559543

560544
# this is the GenericFunctionNodeData for packed types
@@ -587,7 +571,7 @@ function FactorCompute(
587571
solverData.inflation,
588572
)
589573

590-
if solverData.fnc isa FactorSolverCache
574+
if solverData.fnc isa FactorCache
591575
solvercache = solverData.fnc
592576
else
593577
solvercache = nothing
@@ -619,22 +603,22 @@ end
619603
#TODO make sure getFactorOperationalMemoryType is obsolete
620604
function getFactorOperationalMemoryType(dummy)
621605
return error(
622-
"Please extend your workspace with function getFactorOperationalMemoryType(<:AbstractParams) for your usecase, e.g. IncrementalInference uses `CommonConvWrapper <: FactorSolverCache`",
606+
"Please extend your workspace with function getFactorOperationalMemoryType(<:AbstractParams) for your usecase, e.g. IncrementalInference uses `CommonConvWrapper <: FactorCache`",
623607
)
624608
end
625609
function getFactorOperationalMemoryType(dfg::AbstractDFG)
626610
return getFactorOperationalMemoryType(getSolverParams(dfg))
627611
end
628612

629-
function typeModuleName(variableType::VariableStateType)
613+
function typeModuleName(variableType::StateType)
630614
Base.depwarn("typeModuleName is obsolete", :typeModuleName)
631615
io = IOBuffer()
632616
ioc = IOContext(io, :module => DistributedFactorGraphs)
633617
show(ioc, typeof(variableType))
634618
return String(take!(io))
635619
end
636620

637-
typeModuleName(varT::Type{<:VariableStateType}) = typeModuleName(varT())
621+
typeModuleName(varT::Type{<:StateType}) = typeModuleName(varT())
638622

639623
## ================================================================================
640624
## Deprecated in v0.25

src/DistributedFactorGraphs.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ export DFG
8787
export GraphsDFGs, GraphsDFG
8888

8989
##
90-
export getVariableState, getFactorState # FIXME these were questioned and being reviewed again for name, other than that they are checked.
90+
export getState, getFactorState # FIXME these were questioned and being reviewed again for name, other than that they are checked.
9191

9292
## CRUD Matrix
9393
# export addVariable!, getVariable, mergeVariable!, deleteVariable!
9494
# export addVariables!, getVariables, mergeVariables!, deleteVariables!
9595
# export addFactor!, getFactor, mergeFactor!, deleteFactor!
9696
# export addFactors!, getFactors, mergeFactors!, deleteFactors!
9797

98-
# export addVariableState!, getVariableState, mergeVariableState!, deleteVariableState!
99-
# export addVariableStates!, getVariableStates, mergeVariableStates!, deleteVariableStates!
98+
# export addState!, getState, mergeState!, deleteState!
99+
# export addStates!, getStates, mergeStates!, deleteStates!
100100

101101
# export addBlobentry!, getBlobentry, mergeBlobentry!, deleteBlobentry! # historic for VariableBlobentry
102102
# export addBlobentries!, getBlobentries, mergeBlobentries!, deleteBlobentries!
@@ -118,7 +118,7 @@ export getVariableState, getFactorState # FIXME these were questioned and being
118118
# export addGraphBlobentryMetadata!, getGraphBlobentryMetadata, mergeGraphBlobentryMetadata!, deleteGraphBlobentryMetadata!
119119

120120
## list
121-
# export listVariables, listFactors, listVariableStates, listBlobentries, listFactorBlobEntries, listGraphBlobentries, listAgentBlobentries
121+
# export listVariables, listFactors, listStates, listBlobentries, listFactorBlobEntries, listGraphBlobentries, listAgentBlobentries
122122
# export listVariableMetadata, listFactorMetadata, listAgentMetadata, listGraphMetadata
123123
# export listVariableBlobentryMetadata, listFactorBlobentryMetadata, listAgentBlobentryMetadata, listGraphBlobentryMetadata
124124

@@ -128,7 +128,7 @@ export getVariableState, getFactorState # FIXME these were questioned and being
128128

129129
export AbstractObservation, AbstractPackedObservation
130130
export PriorObservation, RelativeObservation
131-
export FactorSolverCache
131+
export FactorCache
132132

133133
#TODO
134134
export PackedBelief
@@ -235,7 +235,7 @@ export removeTags! #TODO do we want this one
235235
# Variable
236236
##------------------------------------------------------------------------------
237237
# Abstract Variable Data
238-
export VariableStateType
238+
export StateType
239239

240240
# accessors
241241
export getSolverDataDict
@@ -260,8 +260,7 @@ export getMetadata,
260260
emptyMetadata!
261261

262262
# CRUD & SET
263-
export getVariableStates,
264-
addVariableState!, mergeVariableState!, deleteVariableState!, listVariableStates
263+
export getStates, addState!, mergeState!, deleteState!, listStates
265264

266265
# PPE
267266
##------------------------------------------------------------------------------
@@ -280,9 +279,9 @@ export getPPE,
280279

281280
# Variable Node Data
282281
##------------------------------------------------------------------------------
283-
export VariableState, PackedVariableState
282+
export State, PackedState
284283

285-
export packVariableState, unpackVariableState
284+
export packState, unpackState
286285

287286
export getSolvedCount,
288287
isSolved, setSolvedCount!, isInitialized, isMarginalized, setMarginalized!

src/entities/DFGFactor.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const PackedBelief = AbstractPackedBelief
1919

2020
# TODO https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/pull/1127#discussion_r2154672975
2121
# and #1138
22-
abstract type AbstractFactorSolverCache end #
23-
const FactorSolverCache = AbstractFactorSolverCache #
22+
abstract type AbstractFactorCache end #
23+
const FactorCache = AbstractFactorCache #
2424

2525
##==============================================================================
2626

@@ -35,11 +35,6 @@ const FactorSolverCache = AbstractFactorSolverCache #
3535
inflation::Float64 = 0.0
3636
end
3737

38-
# TODO should we move non FactorSolverCache to FactorCompute:
39-
# fnc, multihypo, nullhypo, inflation ?
40-
# that way we split solverData <: FactorSolverCache and constants
41-
# TODO see if above ever changes?
42-
4338
## Constructors
4439

4540
##==============================================================================
@@ -225,7 +220,7 @@ Base.@kwdef struct FactorCompute{FT <: AbstractObservation, N} <: AbstractGraphF
225220
"""Temporary, non-persistent memory used internally by the solver for intermediate numerical computations and buffers.
226221
`solvercache` is lazily allocated and only used during factor operations; it is not serialized or retained after solving.
227222
Accessors: [`getCache`](@ref), [`setCache!`](@ref)"""
228-
solvercache::Base.RefValue{<:FactorSolverCache} #TODO easy of use vs. performance as container is abstract in any case.
223+
solvercache::Base.RefValue{<:FactorCache} #TODO easy of use vs. performance as container is abstract in any case.
229224
end
230225

231226
##------------------------------------------------------------------------------
@@ -251,7 +246,7 @@ function FactorCompute(
251246
end
252247

253248
if isnothing(cache)
254-
solvercache = Ref{FactorSolverCache}()
249+
solvercache = Ref{FactorCache}()
255250
else
256251
solvercache = Ref(cache)
257252
end

0 commit comments

Comments
 (0)