Skip to content

Commit 7f9481d

Browse files
committed
more cleanup and unexporting functions
1 parent 55b181f commit 7f9481d

11 files changed

Lines changed: 137 additions & 224 deletions

File tree

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,3 @@ end
4848
StructTypes.StructType(::Type{Blobentry}) = StructTypes.UnorderedStruct()
4949
StructTypes.idproperty(::Type{Blobentry}) = :id
5050
StructTypes.omitempties(::Type{Blobentry}) = (:id,)
51-
52-
_fixtimezone(cts::NamedTuple) = ZonedDateTime(cts.utc_datetime * "+00")

src/Deprecated.jl

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,104 @@ function mergeGraphVariableData!(args...)
5151
)
5252
end
5353

54+
#NOTE List types funcction do not fit verb noun and will be deprecated.
55+
# should return types
56+
57+
"""
58+
$SIGNATURES
59+
60+
Return `Vector{Symbol}` of all unique variable types in factor graph.
61+
"""
62+
function lsTypes(dfg::AbstractDFG)
63+
vars = getVariables(dfg)
64+
alltypes = Set{Symbol}()
65+
for v in vars
66+
varType = Symbol(typeof(getVariableType(v)))
67+
push!(alltypes, varType)
68+
end
69+
return collect(alltypes)
70+
end
71+
72+
"""
73+
$SIGNATURES
74+
75+
Return `::Dict{Symbol, Vector{Symbol}}` of all unique variable types with labels in a factor graph.
76+
"""
77+
function lsTypesDict(dfg::AbstractDFG)
78+
vars = getVariables(dfg)
79+
alltypes = Dict{Symbol, Vector{Symbol}}()
80+
for v in vars
81+
varType = Symbol(typeof(getVariableType(v)))
82+
d = get!(alltypes, varType, Symbol[])
83+
push!(d, v.label)
84+
end
85+
return alltypes
86+
end
87+
88+
"""
89+
$SIGNATURES
90+
91+
Return `Vector{Symbol}` of all unique factor types in factor graph.
92+
"""
93+
function lsfTypes(dfg::AbstractDFG)
94+
facs = getFactors(dfg)
95+
alltypes = Set{Symbol}()
96+
for f in facs
97+
facType = typeof(getFactorType(f)) |> nameof
98+
push!(alltypes, facType)
99+
end
100+
return collect(alltypes)
101+
end
102+
103+
"""
104+
$SIGNATURES
105+
106+
Return `::Dict{Symbol, Vector{Symbol}}` of all unique factors types with labels in a factor graph.
107+
"""
108+
function lsfTypesDict(dfg::AbstractDFG)
109+
facs = getFactors(dfg)
110+
alltypes = Dict{Symbol, Vector{Symbol}}()
111+
for f in facs
112+
facType = typeof(getFactorType(f)) |> nameof
113+
d = get!(alltypes, facType, Symbol[])
114+
push!(d, f.label)
115+
end
116+
return alltypes
117+
end
118+
119+
# solvekey is deprecated and sync!/copyto! is the better verb.
120+
#TODO replace with syncVariableStates! or similar
121+
"""
122+
$SIGNATURES
123+
Duplicate a `solveKey`` into a destination from a source.
124+
125+
Notes
126+
- Can copy between graphs, or to different solveKeys within one graph.
127+
"""
128+
function cloneSolveKey!(
129+
dest_dfg::AbstractDFG,
130+
dest::Symbol,
131+
src_dfg::AbstractDFG,
132+
src::Symbol;
133+
solvable::Int = 0,
134+
labels = intersect(ls(dest_dfg; solvable = solvable), ls(src_dfg; solvable = solvable)),
135+
verbose::Bool = false,
136+
)
137+
#
138+
for x in labels
139+
sd = deepcopy(getVariableState(getVariable(src_dfg, x), src))
140+
copytoVariableState!(dest_dfg, x, dest, sd)
141+
end
142+
143+
return nothing
144+
end
145+
146+
function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...)
147+
#
148+
@assert dest != src "Must copy to a different solveKey within the same graph, $dest."
149+
return cloneSolveKey!(dfg, dest, dfg, src; kw...)
150+
end
151+
54152
## ================================================================================
55153
## Deprecated in v0.27
56154
##=================================================================================

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ export getVariableStates,
218218
addVariableState!,
219219
mergeVariableState!,
220220
deleteVariableState!,
221-
listVariableStates,
222-
cloneSolveKey!
221+
listVariableStates
223222

224223
# PPE
225224
##------------------------------------------------------------------------------
@@ -245,7 +244,7 @@ export packVariableState, unpackVariableState
245244
export getSolvedCount,
246245
isSolved, setSolvedCount!, isInitialized, isMarginalized, setMarginalized!
247246

248-
export getNeighborhood, listNeighbors, _getDuplicatedEmptyDFG
247+
export listNeighborhood, listNeighbors
249248
export findFactorsBetweenNaive
250249
export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph!
251250

@@ -298,7 +297,6 @@ export isValidLabel
298297

299298
## List
300299
export ls, lsf, ls2
301-
export lsTypes, lsfTypes, lsTypesDict, lsfTypesDict
302300
export lsWho
303301
export isPrior, lsfPriors
304302
export hasTags, hasTagsNeighbors

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
2-
function getDFGMetadata(fg::GraphsDFG)
3-
metafields = Set(fieldnames(GraphsDFG))
4-
setdiff!(metafields, [:g, :solverParams])
5-
metaprops = NamedTuple(k => getproperty(fg, k) for k in metafields)
6-
return metaprops
7-
end
8-
91
function hasVariable(dfg::GraphsDFG, label::Symbol)
102
return haskey(dfg.g.variables, label)
113
end
@@ -51,43 +43,6 @@ function addVariable!(
5143
return addVariable!(dfg, VD(variable))
5244
end
5345

54-
#moved to abstract
55-
# function addFactor!(dfg::GraphsDFG{<:AbstractParams, V, F}, variables::Vector{<:V}, factor::F)::F where {V <: AbstractDFGVariable, F <: AbstractDFGFactor}
56-
#
57-
# #TODO should this be an error
58-
# if haskey(dfg.g.factors, factor.label)
59-
# error("Factor '$(factor.label)' already exists in the factor graph")
60-
# end
61-
# # for v in variables
62-
# # if !(v.label in keys(dfg.g.metaindex[:label]))
63-
# # error("Variable '$(v.label)' not found in graph when creating Factor '$(factor.label)'")
64-
# # end
65-
# # end
66-
#
67-
# variableLabels = map(v->v.label, variables)
68-
#
69-
# resize!(factor._variableOrderSymbols, length(variableLabels))
70-
# factor._variableOrderSymbols .= variableLabels
71-
# # factor._variableOrderSymbols = copy(variableLabels)
72-
#
73-
# @assert FactorGraphs.addFactor!(dfg.g, variableLabels, factor)
74-
# return factor
75-
# end
76-
#
77-
# function addFactor!(dfg::GraphsDFG{<:AbstractParams, <:AbstractDFGVariable, F}, variableLabels::Vector{Symbol}, factor::F)::F where F <: AbstractDFGFactor
78-
# #TODO should this be an error
79-
# if haskey(dfg.g.factors, factor.label)
80-
# error("Factor '$(factor.label)' already exists in the factor graph")
81-
# end
82-
#
83-
# resize!(factor._variableOrderSymbols, length(variableLabels))
84-
# factor._variableOrderSymbols .= variableLabels
85-
#
86-
# @assert FactorGraphs.addFactor!(dfg.g, variableLabels, factor)
87-
#
88-
# return factor
89-
# end
90-
9146
function addFactor!(
9247
dfg::GraphsDFG{<:AbstractParams, <:AbstractDFGVariable, F},
9348
factor::F,

src/entities/DFGFactor.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,6 @@ end
359359
##------------------------------------------------------------------------------
360360
## Constructors
361361

362-
#NOTE I feel like a want to force a variableOrderSymbols
363-
function FactorSkeleton(
364-
id::Union{UUID, Nothing},
365-
label::Symbol,
366-
variableOrderSymbols::Vector{Symbol} = Symbol[],
367-
)
368-
@warn "FactorSkeleton(id::Union{UUID, Nothing}...) is deprecated, use FactorSkeleton(label, variableOrderSymbols) instead"
369-
return FactorSkeleton(id, label, Set{Symbol}(), variableOrderSymbols)
370-
end
371362
function FactorSkeleton(
372363
label::Symbol,
373364
variableOrderSymbols::Vector{Symbol};
@@ -377,10 +368,6 @@ function FactorSkeleton(
377368
return FactorSkeleton(id, label, tags, variableOrderSymbols)
378369
end
379370

380-
StructTypes.StructType(::Type{FactorSkeleton}) = StructTypes.OrderedStruct()
381-
StructTypes.idproperty(::Type{FactorSkeleton}) = :id
382-
StructTypes.omitempties(::Type{FactorSkeleton}) = (:id,)
383-
384371
##==============================================================================
385372
## Define factor levels
386373
##==============================================================================

src/entities/DFGVariable.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ function VariableState(variableType::VariableStateType; kwargs...)
8989
return VariableState{typeof(variableType)}(; kwargs...)
9090
end
9191

92+
93+
function VariableState(state::VariableState; kwargs...)
94+
return VariableState{typeof(getVariableType(state))}(;
95+
(key => deepcopy(getproperty(state, key)) for key in fieldnames(VariableState))...,
96+
kwargs...,
97+
)
98+
end
9299
##==============================================================================
93100
## PackedVariableState.jl
94101
##==============================================================================
@@ -452,10 +459,6 @@ function VariableSkeleton(
452459
return VariableSkeleton(id, label, tags)
453460
end
454461

455-
StructTypes.StructType(::Type{VariableSkeleton}) = StructTypes.UnorderedStruct()
456-
StructTypes.idproperty(::Type{VariableSkeleton}) = :id
457-
StructTypes.omitempties(::Type{VariableSkeleton}) = (:id,)
458-
459462
##==============================================================================
460463
# Define variable levels
461464
##==============================================================================
@@ -473,13 +476,13 @@ function VariableSummary(v::VariableCompute)
473476
v.id,
474477
v.label,
475478
v.timestamp,
476-
deepcopy(v.tags),
479+
copy(v.tags),
477480
deepcopy(v.ppeDict),
478481
Symbol(typeof(getVariableType(v))),
479482
v.dataDict,
480483
)
481484
end
482485

483486
function VariableSkeleton(v::VariableDataLevel1)
484-
return VariableSkeleton(v.id, v.label, deepcopy(v.tags))
487+
return VariableSkeleton(v.id, v.label, copy(v.tags))
485488
end

0 commit comments

Comments
 (0)