Skip to content

Commit b9a43ec

Browse files
authored
Remove v0.28 deprecations and update filters (#1204)
1 parent 167e023 commit b9a43ec

File tree

10 files changed

+115
-648
lines changed

10 files changed

+115
-648
lines changed

src/Deprecated.jl

Lines changed: 29 additions & 312 deletions
Original file line numberDiff line numberDiff line change
@@ -323,325 +323,42 @@ function setTags!(node, tags::Union{Vector{Symbol}, Set{Symbol}})
323323
return union!(node.tags, tags)
324324
end
325325

326-
## ================================================================================
327-
## Deprecated in v0.28
328-
##=================================================================================
329-
abstract type AbstractRelativeMinimize <: RelativeObservation end
330-
abstract type AbstractManifoldMinimize <: RelativeObservation end
331-
332-
const SkeletonDFGVariable = VariableSkeleton
333-
const DFGVariableSummary = VariableSummary
334-
const PackedVariable = VariableDFG
335-
const Variable = VariableDFG
336-
const DFGVariable = VariableCompute
337-
const SkeletonDFGFactor = FactorSkeleton
338-
const DFGFactorSummary = FactorSummary
339-
const DFGFactor = FactorCompute
340-
const PackedFactor = FactorDFG
341-
const Factor = FactorDFG
342-
const AbstractPrior = PriorObservation
343-
const AbstractRelative = RelativeObservation
344-
const AbstractParams = AbstractDFGParams
345-
const InferenceVariable = StateType{Any}
346-
const InferenceType = AbstractPackedObservation
347-
const PackedSamplableBelief = PackedBelief
348-
const getVariableState = getState
349-
const addVariableState! = addState!
350-
const mergeVariableState! = mergeState!
351-
const deleteVariableState! = deleteState!
352-
const listVariableStates = listStates
353-
const VariableState = State
354-
const VariableStateType = StateType
355-
const copytoVariableState! = copytoState!
356-
357-
# """
358-
# $SIGNATURES
359-
# Set solver data structure stored in a variable.
360-
# """
361-
function setSolverData!(v::VariableCompute, data::State, key::Symbol = :default)
362-
Base.depwarn(
363-
"setSolverData!(v::VariableCompute, data::State, key::Symbol = :default) is deprecated, use mergeState! instead.",
364-
:setSolverData!,
365-
)
366-
@assert key == data.solveKey "State.solveKey=:$(data.solveKey) does not match requested :$(key)"
367-
return v.states[key] = data
368-
end
369-
370-
@deprecate mergeVariableSolverData!(args...; kwargs...) mergeState!(args...; kwargs...)
371-
372-
function mergeVariableData!(args...)
373-
return error(
374-
"mergeVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
375-
)
376-
end
377-
function mergeGraphVariableData!(args...)
378-
return error(
379-
"mergeGraphVariableData! is obsolete, use mergeState! for state, PPEs are obsolete",
380-
)
381-
end
382-
383326
# """
384327
# $(SIGNATURES)
385-
# Gives back all factor labels that fit the bill:
386-
# lsWho(dfg, :Pose3)
387-
388-
# Notes
389-
# - Returns `Vector{Symbol}`
390-
391-
# Dev Notes
392-
# - Cloud versions will benefit from less data transfer
393-
# - `ls(dfg::C, ::T) where {C <: CloudDFG, T <: ..}`
394-
395-
# Related
396-
397-
# ls, lsf, lsfPriors
398-
# """
399-
function lsWho(dfg::AbstractDFG, type::Symbol)
400-
Base.depwarn("lsWho(dfg, type) is deprecated, use ls(dfg, type) instead.", :lsWho)
401-
vars = getVariables(dfg)
402-
labels = Symbol[]
403-
for v in vars
404-
varType = typeof(getStateKind(v)) |> nameof
405-
varType == type && push!(labels, v.label)
406-
end
407-
return labels
408-
end
409-
410-
# solvekey is deprecated and sync!/copyto! is the better verb.
411-
#TODO replace with syncStates! or similar
328+
# Get a matrix indicating relationships between variables and factors. Rows are
329+
# all factors, columns are all variables, and each cell contains either nothing or
330+
# the symbol of the relating factor. The first row and first column are factor and
331+
# variable headings respectively.
332+
# Note:
333+
# - rather use getBiadjacencyMatrix
334+
# - Returns either of `::Matrix{Union{Nothing, Symbol}}`
412335
# """
413-
# $SIGNATURES
414-
# Duplicate a `solveKey`` into a destination from a source.
415-
416-
# Notes
417-
# - Can copy between graphs, or to different solveKeys within one graph.
418-
# """
419-
function cloneSolveKey!(
420-
dest_dfg::AbstractDFG,
421-
dest::Symbol,
422-
src_dfg::AbstractDFG,
423-
src::Symbol;
424-
solvable::Int = 0,
425-
labels = intersect(ls(dest_dfg; solvable = solvable), ls(src_dfg; solvable = solvable)),
426-
verbose::Bool = false,
336+
# Deprecated in favor of getBiadjacencyMatrix as it is not efficient for large graphs.
337+
function getAdjacencyMatrixSymbols(
338+
dfg::AbstractDFG;
339+
solvableFilter::Union{Nothing, Function} = nothing,
427340
)
428341
#
429-
for x in labels
430-
sd = deepcopy(getState(getVariable(src_dfg, x), src))
431-
copytoState!(dest_dfg, x, dest, sd)
432-
end
433-
434-
return nothing
435-
end
436-
437-
function cloneSolveKey!(dfg::AbstractDFG, dest::Symbol, src::Symbol; kw...)
438-
#
439-
@assert dest != src "Must copy to a different solveKey within the same graph, $dest."
440-
return cloneSolveKey!(dfg, dest, dfg, src; kw...)
441-
end
442-
443-
#TODO make a replacement if used a lot... not a good function, as it's not complete.
444-
# """
445-
# $(SIGNATURES)
446-
# Convenience function to get all the metadata of a DFG
447-
# """
448-
function getDFGInfo(dfg::AbstractDFG)
449-
Base.depwarn("getDFGInfo is deprecated and needs a replacement.", :getDFGInfo)
450-
return (
451-
graphDescription = getDescription(dfg),
452-
agentLabel = getAgentLabel(dfg),
453-
graphLabel = getGraphLabel(dfg),
454-
# agentBloblets = getAgentBloblets(dfg),
455-
# graphBloblets = getGraphBloblets(dfg),
456-
solverParams = getSolverParams(dfg),
342+
varLabels = sort(map(v -> v.label, getVariables(dfg; solvableFilter)))
343+
factLabels = sort(map(f -> f.label, getFactors(dfg; solvableFilter)))
344+
vDict = Dict(varLabels .=> [1:length(varLabels)...] .+ 1)
345+
346+
adjMat = Matrix{Union{Nothing, Symbol}}(
347+
nothing,
348+
length(factLabels) + 1,
349+
length(varLabels) + 1,
457350
)
458-
end
459-
460-
function listSolveKeys(
461-
variable::VariableCompute,
462-
filterSolveKeys::Union{Regex, Nothing} = nothing,
463-
skeys = Set{Symbol}(),
464-
)
465-
Base.depwarn("listSolveKeys is deprecated, use listStates instead.", :listSolveKeys)
466-
#
467-
for ky in keys(refStates(variable))
468-
push!(skeys, ky)
469-
end
470-
471-
#filter the solveKey set with filterSolveKeys regex
472-
!isnothing(filterSolveKeys) &&
473-
return filter!(k -> occursin(filterSolveKeys, string(k)), skeys)
474-
return skeys
475-
end
476-
477-
function listSolveKeys(
478-
dfg::AbstractDFG,
479-
lbl::Symbol,
480-
filterSolveKeys::Union{Regex, Nothing} = nothing,
481-
skeys = Set{Symbol}(),
482-
)
483-
return listSolveKeys(getVariable(dfg, lbl), filterSolveKeys, skeys)
484-
end
485-
#
486-
487-
function listSolveKeys(
488-
dfg::AbstractDFG,
489-
filterVariables::Union{Type{<:StateType}, Regex, Nothing} = nothing;
490-
filterSolveKeys::Union{Regex, Nothing} = nothing,
491-
tags::Vector{Symbol} = Symbol[],
492-
solvable::Int = 0,
493-
)
494-
#
495-
skeys = Set{Symbol}()
496-
varList = listVariables(dfg, filterVariables; tags = tags, solvable = solvable)
497-
for vs in varList #, ky in keys(refStates(getVariable(dfg, vs)))
498-
listSolveKeys(dfg, vs, filterSolveKeys, skeys)
499-
end
500-
501-
# done inside the loop
502-
# #filter the solveKey set with filterSolveKeys regex
503-
# !isnothing(filterSolveKeys) && return filter!(k -> occursin(filterSolveKeys, string(k)), skeys)
504-
505-
return skeys
506-
end
507-
508-
const listSupersolves = listSolveKeys
509-
510-
#TODO mergeBlobentries! does not fit with merge definition, should probably be updated to copyto or sync.
511-
# leaving here until it is done.
512-
# Add a blob entry into the destination variable which already exists in a source variable.
513-
function mergeBlobentries!(
514-
dst::AbstractDFG,
515-
dlbl::Symbol,
516-
src::AbstractDFG,
517-
slbl::Symbol,
518-
bllb::Union{Symbol, UUID, <:AbstractString, Regex},
519-
)
520-
#
521-
_makevec(s) = [s;]
522-
_makevec(s::AbstractVector) = s
523-
des_ = getBlobentry(src, slbl, bllb)
524-
des = _makevec(des_)
525-
# don't add data entries that already exist
526-
dde = listBlobentries(dst, dlbl)
527-
# HACK, verb list should just return vector of Symbol. NCE36
528-
_getid(s) = s
529-
_getid(s::Blobentry) = s.id
530-
uids = _getid.(dde) # (s->s.id).(dde)
531-
filter!(s -> !(_getid(s) in uids), des)
532-
# add any data entries not already in the destination variable, by uuid
533-
return addBlobentry!.(dst, dlbl, des)
534-
end
535-
536-
function mergeBlobentries!(
537-
dst::AbstractDFG,
538-
dlbl::Symbol,
539-
src::AbstractDFG,
540-
slbl::Symbol,
541-
::Colon = :,
542-
)
543-
des = listBlobentries(src, slbl)
544-
# don't add data entries that already exist
545-
uids = listBlobentries(dst, dlbl)
546-
# verb list should just return vector of Symbol. NCE36
547-
filter!(s -> !(s in uids), des)
548-
if 0 < length(des)
549-
union(((s -> mergeBlobentries!(dst, dlbl, src, slbl, s)).(des))...)
351+
# Set row/col headings
352+
adjMat[2:end, 1] = factLabels
353+
adjMat[1, 2:end] = varLabels
354+
for (fIndex, factLabel) in enumerate(factLabels)
355+
factVars = listNeighbors(dfg, getFactor(dfg, factLabel); solvable)
356+
map(vLabel -> adjMat[fIndex + 1, vDict[vLabel]] = factLabel, factVars)
550357
end
358+
return adjMat
551359
end
552360

553-
function mergeBlobentries!(
554-
dest::AbstractDFG,
555-
src::AbstractDFG,
556-
w...;
557-
varList::AbstractVector = listVariables(dest) |> sortDFG,
558-
)
559-
@showprogress 1 "merging data entries" for vl in varList
560-
mergeBlobentries!(dest, vl, src, vl, w...)
561-
end
562-
return varList
563-
end
564-
565-
function getBlobentriesVariables(
566-
dfg::AbstractDFG,
567-
bLblPattern::Regex;
568-
varList::AbstractVector{Symbol} = sort(listVariables(dfg); lt = natural_lt),
569-
dropEmpties::Bool = false,
361+
@deprecate findVariableNearTimestamp(args...; kwargs...) findVariablesNearTimestamp(
362+
args...;
363+
kwargs...,
570364
)
571-
Base.depwarn(
572-
"getBlobentriesVariables is deprecated, use gatherBlobentries instead.",
573-
:getBlobentriesVariables,
574-
)
575-
RETLIST = Vector{Vector{Blobentry}}()
576-
@showprogress "Get entries matching $bLblPattern" for vl in varList
577-
bes = filter(s -> occursin(bLblPattern, string(s.label)), listBlobentries(dfg, vl))
578-
# only push to list if there are entries on this variable
579-
(!dropEmpties || 0 < length(bes)) ? nothing : continue
580-
push!(RETLIST, bes)
581-
end
582-
583-
return RETLIST
584-
end
585-
586-
function getBlobentries(dfg::AbstractDFG, label::Symbol, regex::Regex)
587-
Base.depwarn(
588-
"getBlobentries(dfg, label, ::Regex) is deprecated, use getBlobentries(dfg, label; labelFilter=contains(regex)) instead.",
589-
:getBlobentries,
590-
)
591-
return entries = getBlobentries(dfg, label; labelFilter = contains(regex))
592-
end
593-
594-
function getBlobentries(dfg::AbstractDFG, label::Symbol, skey::AbstractString)
595-
Base.depwarn(
596-
"getBlobentries(dfg, label, regex::AbstractString) is deprecated, use getBlobentries(dfg, label; labelFilter=contains(regex)) instead.",
597-
:getBlobentries,
598-
)
599-
return getBlobentries(dfg, label, Regex(string(skey)))
600-
end
601-
602-
function getfirstBlobentry(var::AbstractGraphVariable, blobId::UUID)
603-
Base.depwarn(
604-
"getfirstBlobentry(var, blobId) is deprecated, use getfirstBlobentry(var; blobidFilter = ==(string(blobId))) instead.",
605-
:getfirstBlobentry,
606-
)
607-
return getfirstBlobentry(var; blobidFilter = ==(string(blobId)))
608-
end
609-
610-
function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, blobId::UUID)
611-
Base.depwarn(
612-
"getfirstBlobentry(dfg, label, blobId) is deprecated, use getfirstBlobentry(dfg, label; blobidFilter = ==(string(blobId))) instead.",
613-
:getfirstBlobentry,
614-
)
615-
return getfirstBlobentry(dfg, label; blobidFilter = ==(string(blobId)))
616-
end
617-
618-
function getfirstBlobentry(var::AbstractGraphVariable, key::Regex)
619-
Base.depwarn(
620-
"getfirstBlobentry(var, key::Regex) is deprecated, use getfirstBlobentry(var; labelFilter=contains(key)) instead.",
621-
:getfirstBlobentry,
622-
)
623-
return getfirstBlobentry(var; labelFilter = contains(key))
624-
end
625-
626-
function getfirstBlobentry(dfg::AbstractDFG, label::Symbol, key::Regex)
627-
Base.depwarn(
628-
"getfirstBlobentry(dfg, label, key::Regex) is deprecated, use getfirstBlobentry(dfg, label; labelFilter=contains(key)) instead.",
629-
:getfirstBlobentry,
630-
)
631-
return getfirstBlobentry(dfg, label; labelFilter = contains(key))
632-
end
633-
634-
macro defVariable(args...)
635-
return esc(:(DFG.@defStateType $(args...)))
636-
end
637-
638-
@deprecate getFactorFunction(args...) getObservation(args...)
639-
@deprecate getFactorType(args...) getObservation(args...)
640-
641-
setMetadata!(args...) = error("setMetadata is obsolete, use Bloblets instead.")
642-
643-
updateData!(args...; kwargs...) = error("updateData! is obsolete.")
644-
updateBlob!(args...; kwargs...) = error("updateBlob! is obsolete.")
645-
getData(args...; kwargs...) = error("getData is obsolete, use loadBlob_Variable")
646-
addData!(args...; kwargs...) = error("addData! is obsolete, use saveBlob_Variable!")
647-
deleteData!(args...; kwargs...) = error("deleteData! is obsolete, use deleteBlob_Variable!")

0 commit comments

Comments
 (0)