From f270d5a42d30ba5e36a0f395dd1a244c4dcffaa4 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 1 Apr 2026 11:11:38 +0200 Subject: [PATCH 1/3] Refactor filtering arguments in DFG functions to use 'whereNoun' --- NEWS.md | 7 ++ src/DataBlobs/services/BlobEntry.jl | 56 ++++++------- src/Deprecated.jl | 48 +++++------ src/GraphsDFG/services/GraphsDFG.jl | 124 ++++++++++++++-------------- src/services/AbstractDFG.jl | 40 +++++---- src/services/Bloblet.jl | 2 +- src/services/DFGVariable.jl | 28 +++---- src/services/find.jl | 8 +- src/services/list.jl | 28 +++---- test/iifInterfaceTests.jl | 40 ++++----- test/testBlocks.jl | 94 ++++++++++----------- 11 files changed, 240 insertions(+), 235 deletions(-) diff --git a/NEWS.md b/NEWS.md index eb123556..9fce2e7c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,13 @@ Listing news on any major breaking changes in DFG. For regular changes, see int # v0.29 - `AbstractPointParametricEst` (`MeanMaxPPE`) and related `PPE` functions are obsolete, see #1133. +- Rename filter keyword arguments to `where`-prefixed form: + - `solvableFilter` -> `whereSolvable` + - `labelFilter` -> `whereLabel` + - `tagsFilter` -> `whereTags` + - `typeFilter` -> `whereType` + - `blobidFilter` -> `whereBlobid` + - `variableLabelFilter` -> `whereVariableLabel` # v0.28 - Reading or deserialzing of factor graphs created prior to v0.25 are no longer suppoted with the complete removal of User/Robot/Session diff --git a/src/DataBlobs/services/BlobEntry.jl b/src/DataBlobs/services/BlobEntry.jl index a869dfce..b2098c91 100644 --- a/src/DataBlobs/services/BlobEntry.jl +++ b/src/DataBlobs/services/BlobEntry.jl @@ -12,12 +12,12 @@ end function getBlobentries( node; - labelFilter::Union{Nothing, Function} = nothing, - blobidFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereBlobid::Union{Nothing, Function} = nothing, ) entries = collect(values(refBlobentries(node))) - filterDFG!(entries, labelFilter, getLabel) - filterDFG!(entries, blobidFilter, x -> string(x.blobid)) + filterDFG!(entries, whereLabel, getLabel) + filterDFG!(entries, whereBlobid, x -> string(x.blobid)) return entries end @@ -207,10 +207,10 @@ end function getVariableBlobentries( dfg::AbstractDFG, variableLabel::Symbol; - labelFilter::Union{Nothing, Function} = nothing, - blobidFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereBlobid::Union{Nothing, Function} = nothing, ) - return getBlobentries(getVariable(dfg, variableLabel); labelFilter, blobidFilter) + return getBlobentries(getVariable(dfg, variableLabel); whereLabel, whereBlobid) end function listVariableBlobentries(dfg::AbstractDFG, variableLabel::Symbol) @@ -228,10 +228,10 @@ end function getFactorBlobentries( dfg::AbstractDFG, factorLabel::Symbol; - labelFilter::Union{Nothing, Function} = nothing, - blobidFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereBlobid::Union{Nothing, Function} = nothing, ) - return getBlobentries(getFactor(dfg, factorLabel); labelFilter, blobidFilter) + return getBlobentries(getFactor(dfg, factorLabel); whereLabel, whereBlobid) end function listFactorBlobentries(dfg::AbstractDFG, factorLabel::Symbol) @@ -328,22 +328,22 @@ end function gatherBlobentries( dfg::AbstractDFG; - labelFilter::Union{Nothing, Function} = nothing, - blobidFilter::Union{Nothing, Function} = nothing, - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - variableLabelFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereBlobid::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereVariableLabel::Union{Nothing, Function} = nothing, ) vls = listVariables( dfg; - solvableFilter, - tagsFilter, - typeFilter, - labelFilter = variableLabelFilter, + whereSolvable, + whereTags, + whereType, + whereLabel = whereVariableLabel, ) return map(vls) do vl - return vl => getVariableBlobentries(dfg, vl; labelFilter, blobidFilter) + return vl => getVariableBlobentries(dfg, vl; whereLabel, whereBlobid) end end const collectBlobentries = gatherBlobentries @@ -356,12 +356,12 @@ Also see: [`getBlobentry`](@ref) """ function getfirstBlobentry( node; - labelFilter::Union{Nothing, Function} = nothing, - blobidFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereBlobid::Union{Nothing, Function} = nothing, sortby::Function = getLabel, sortlt::Function = natural_lt, ) - entries = getBlobentries(node; labelFilter, blobidFilter) + entries = getBlobentries(node; whereLabel, whereBlobid) if isempty(entries) return nothing else @@ -372,10 +372,10 @@ end function getfirstVariableBlobentry( dfg::AbstractDFG, label::Symbol; - labelFilter::Union{Nothing, Function} = nothing, - blobidFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereBlobid::Union{Nothing, Function} = nothing, ) - return getfirstBlobentry(getVariable(dfg, label); labelFilter, blobidFilter) + return getfirstBlobentry(getVariable(dfg, label); whereLabel, whereBlobid) end ## ============================================================================= @@ -430,7 +430,7 @@ function incrDataLabelSuffix( hasund = false len = 0 try - de = getfirstVariableBlobentry(dfg, vla; labelFilter = contains(string(bllb))) + de = getfirstVariableBlobentry(dfg, vla; whereLabel = contains(string(bllb))) isnothing(de) && return Symbol(bllb) # no match, return as is bllb = string(bllb) # bllb *= bllb[end] != '_' ? "_" : "" diff --git a/src/Deprecated.jl b/src/Deprecated.jl index becd2687..05338515 100644 --- a/src/Deprecated.jl +++ b/src/Deprecated.jl @@ -279,7 +279,7 @@ function hasTagsNeighbors( ) # Base.depwarn( - "hasTagsNeighbors is deprecated, use listNeighbors with tagsFilter instead", + "hasTagsNeighbors is deprecated, use listNeighbors with whereTags instead", :hasTagsNeighbors, ) # assume only variables or factors are neighbors @@ -337,11 +337,11 @@ end # Deprecated in favor of getBiadjacencyMatrix as it is not efficient for large graphs. function getAdjacencyMatrixSymbols( dfg::AbstractDFG; - solvableFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, ) # - varLabels = sort(map(v -> v.label, getVariables(dfg; solvableFilter))) - factLabels = sort(map(f -> f.label, getFactors(dfg; solvableFilter))) + varLabels = sort(map(v -> v.label, getVariables(dfg; whereSolvable))) + factLabels = sort(map(f -> f.label, getFactors(dfg; whereSolvable))) vDict = Dict(varLabels .=> [1:length(varLabels)...] .+ 1) adjMat = Matrix{Union{Nothing, Symbol}}( @@ -592,8 +592,8 @@ function mergeGraph!( variableLabels::Vector{Symbol}, factorLabels::Vector{Symbol} = lsf(sourceDFG), distance::Int = 0; - solvableFilter = nothing, - tagsFilter = nothing, + whereSolvable = nothing, + whereTags = nothing, kwargs..., ) Base.depwarn( @@ -609,8 +609,8 @@ function mergeGraph!( sourceDFG, union(variableLabels, factorLabels), distance; - solvableFilter, - tagsFilter, + whereSolvable, + whereTags, ) copyGraph!( @@ -665,13 +665,13 @@ function findShortestPathDijkstra( dfg::GraphsDFG, from::Symbol, to::Symbol; - labelFilterVariables::Union{Function, Nothing} = nothing, - labelFilterFactors::Union{Function, Nothing} = nothing, - tagsFilterVariables::Union{Function, Nothing} = nothing, - tagsFilterFactors::Union{Function, Nothing} = nothing, - typeFilterVariables::Union{Function, Nothing} = nothing, - typeFilterFactors::Union{Function, Nothing} = nothing, - solvableFilter::Union{Function, Nothing} = nothing, + whereVariableLabel::Union{Function, Nothing} = nothing, + whereFactorLabel::Union{Function, Nothing} = nothing, + whereVariableTags::Union{Function, Nothing} = nothing, + whereFactorTags::Union{Function, Nothing} = nothing, + whereVariableType::Union{Function, Nothing} = nothing, + whereFactorType::Union{Function, Nothing} = nothing, + whereSolvable::Union{Function, Nothing} = nothing, initialized::Union{Nothing, Bool} = nothing, ) Base.depwarn( @@ -679,23 +679,23 @@ function findShortestPathDijkstra( :findShortestPathDijkstra, ) any_active_filters = any( - .!isnothing.([labelFilterVariables, labelFilterFactors, tagsFilterVariables, tagsFilterFactors, typeFilterVariables, typeFilterFactors, initialized, solvableFilter]), + .!isnothing.([whereVariableLabel, whereFactorLabel, whereVariableTags, whereFactorTags, whereVariableType, whereFactorType, initialized, whereSolvable]), ) if any_active_filters varList = listVariables( dfg; - labelFilter = labelFilterVariables, - tagsFilter = tagsFilterVariables, - typeFilter = typeFilterVariables, - solvableFilter, + whereLabel = whereVariableLabel, + whereTags = whereVariableTags, + whereType = whereVariableType, + whereSolvable, ) fctList = listFactors( dfg; - labelFilter = labelFilterFactors, - tagsFilter = tagsFilterFactors, - typeFilter = typeFilterFactors, - solvableFilter, + whereLabel = whereFactorLabel, + whereTags = whereFactorTags, + whereType = whereFactorType, + whereSolvable, ) varList = if initialized !== nothing diff --git a/src/GraphsDFG/services/GraphsDFG.jl b/src/GraphsDFG/services/GraphsDFG.jl index 4887f08f..7cb02d5c 100644 --- a/src/GraphsDFG/services/GraphsDFG.jl +++ b/src/GraphsDFG/services/GraphsDFG.jl @@ -128,82 +128,82 @@ function deleteFactor!(dfg::GraphsDFG, label::Symbol) end # """ -# tagsFilter = ⊇([:x1]) -# tagsFilter([:x1, :x2]) +# whereTags = ⊇([:x1]) +# whereTags([:x1, :x2]) # true -# tagsFilter = Base.Fix1(in, :x1) -# tagsFilter([:x1, :x2]) +# whereTags = Base.Fix1(in, :x1) +# whereTags([:x1, :x2]) # true # """ function getVariables( dfg::GraphsDFG; - solvableFilter::Union{Nothing, Function} = nothing, - labelFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, ) variables = collect(values(dfg.g.variables)) - filterDFG!(variables, labelFilter, getLabel) - filterDFG!(variables, solvableFilter, getSolvable) - filterDFG!(variables, tagsFilter, refTags) - filterDFG!(variables, typeFilter, getStateKind) + filterDFG!(variables, whereLabel, getLabel) + filterDFG!(variables, whereSolvable, getSolvable) + filterDFG!(variables, whereTags, refTags) + filterDFG!(variables, whereType, getStateKind) return variables end function listVariables( dfg::GraphsDFG; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - labelFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) - if !isnothing(solvableFilter) || !isnothing(tagsFilter) || !isnothing(typeFilter) + if !isnothing(whereSolvable) || !isnothing(whereTags) || !isnothing(whereType) return map( getLabel, - getVariables(dfg; solvableFilter, tagsFilter, typeFilter, labelFilter), + getVariables(dfg; whereSolvable, whereTags, whereType, whereLabel), )::Vector{Symbol} else # Is it ok to continue using the internal keys property? collect(keys(dfg.g.variables)) allowcates a lot. labels = copy(dfg.g.variables.keys) - filterDFG!(labels, labelFilter, string) + filterDFG!(labels, whereLabel, string) return labels end end function getFactors( dfg::GraphsDFG; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - labelFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) factors = collect(values(dfg.g.factors)) - filterDFG!(factors, labelFilter, getLabel) - filterDFG!(factors, solvableFilter, getSolvable) - filterDFG!(factors, tagsFilter, refTags) - filterDFG!(factors, typeFilter, typeof ∘ DFG.getObservation) + filterDFG!(factors, whereLabel, getLabel) + filterDFG!(factors, whereSolvable, getSolvable) + filterDFG!(factors, whereTags, refTags) + filterDFG!(factors, whereType, typeof ∘ DFG.getObservation) return factors end function listFactors( dfg::GraphsDFG; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - labelFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) - if !isnothing(solvableFilter) || !isnothing(tagsFilter) || !isnothing(typeFilter) + if !isnothing(whereSolvable) || !isnothing(whereTags) || !isnothing(whereType) return map( getLabel, - getFactors(dfg; solvableFilter, tagsFilter, typeFilter, labelFilter), + getFactors(dfg; whereSolvable, whereTags, whereType, whereLabel), )::Vector{Symbol} else # Is it ok to continue using the internal keys property? collect(keys(dfg.g.factors)) allowcates a lot. labels = copy(dfg.g.factors.keys) - filterDFG!(labels, labelFilter, string) + filterDFG!(labels, whereLabel, string) return labels end end @@ -216,18 +216,18 @@ end function listNeighbors( dfg::GraphsDFG, label::Symbol; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - solvable::Union{Nothing, Int} = nothing, #TODO deprecated for solvableFilter v0.29 + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + solvable::Union{Nothing, Int} = nothing, #TODO deprecated for whereSolvable v0.29 ) if !isnothing(solvable) Base.depwarn( - "solvable kwarg is deprecated, use kwarg `solvableFilter = (>=solvable)` instead", #v0.29 + "solvable kwarg is deprecated, use kwarg `whereSolvable = (>=solvable)` instead", #v0.29 :listNeighbors, ) - !isnothing(solvableFilter) && - error("Cannot use both solvable and solvableFilter kwargs.") - solvableFilter = >=(solvable) + !isnothing(whereSolvable) && + error("Cannot use both solvable and whereSolvable kwargs.") + whereSolvable = >=(solvable) end if !(hasVariable(dfg, label) || hasFactor(dfg, label)) @@ -239,8 +239,8 @@ function listNeighbors( # Additional filtering # solvable != 0 && filter!(lbl -> _isSolvable(dfg, lbl, solvable), neighbors_ll) - filterDFG!(neighbors_ll, solvableFilter, l -> getSolvable(dfg, l)) - filterDFG!(neighbors_ll, tagsFilter, l -> listTags(dfg, l)) + filterDFG!(neighbors_ll, whereSolvable, l -> getSolvable(dfg, l)) + filterDFG!(neighbors_ll, whereTags, l -> listTags(dfg, l)) # Variable sorting (order is important) if haskey(dfg.g.factors, label) @@ -255,18 +255,18 @@ function listNeighborhood( dfg::GraphsDFG, variableFactorLabels::Vector{Symbol}, distance::Int; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - solvable::Union{Nothing, Int} = nothing, #TODO deprecated for solvableFilter v0.29 + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + solvable::Union{Nothing, Int} = nothing, #TODO deprecated for whereSolvable v0.29 ) if !isnothing(solvable) Base.depwarn( - "solvable kwarg is deprecated, use kwarg `solvableFilter = (>=solvable)` instead", #v0.29 + "solvable kwarg is deprecated, use kwarg `whereSolvable = (>=solvable)` instead", #v0.29 :listNeighborhood, ) - !isnothing(solvableFilter) && - error("Cannot use both solvable and solvableFilter kwargs.") - solvableFilter = >=(solvable) + !isnothing(whereSolvable) && + error("Cannot use both solvable and whereSolvable kwargs.") + whereSolvable = >=(solvable) end # find neighbors at distance to add @@ -278,8 +278,8 @@ function listNeighborhood( allvarfacs = [dfg.g.labels[id] for id in nbhood] - filterDFG!(allvarfacs, solvableFilter, l -> getSolvable(dfg, l)) - filterDFG!(allvarfacs, tagsFilter, l -> listTags(dfg, l)) + filterDFG!(allvarfacs, whereSolvable, l -> getSolvable(dfg, l)) + filterDFG!(allvarfacs, whereTags, l -> listTags(dfg, l)) variableLabels = intersect(listVariables(dfg), allvarfacs) factorLabels = intersect(listFactors(dfg), allvarfacs) @@ -305,10 +305,10 @@ end # Biadjacency Matrix https://en.wikipedia.org/wiki/Adjacency_matrix#Of_a_bipartite_graph function getBiadjacencyMatrix( dfg::GraphsDFG; - solvable::Union{Nothing, Int} = nothing, #TODO deprecated for solvableFilter v0.29 - solvableFilter = isnothing(solvable) ? nothing : >=(solvable), - varLabels = listVariables(dfg; solvableFilter), - factLabels = listFactors(dfg; solvableFilter), + solvable::Union{Nothing, Int} = nothing, #TODO deprecated for whereSolvable v0.29 + whereSolvable = isnothing(solvable) ? nothing : >=(solvable), + varLabels = listVariables(dfg; whereSolvable), + factLabels = listFactors(dfg; whereSolvable), ) varIndex = [dfg.g.labels[s] for s in varLabels] factIndex = [dfg.g.labels[s] for s in factLabels] @@ -505,18 +505,18 @@ function getGraphBlobentry(fg::GraphsDFG, label::Symbol) return fg.graph.blobentries[label] end -function getGraphBlobentries(fg::GraphsDFG; labelFilter::Union{Nothing, Function} = nothing) +function getGraphBlobentries(fg::GraphsDFG; whereLabel::Union{Nothing, Function} = nothing) entries = collect(values(fg.graph.blobentries)) - filterDFG!(entries, labelFilter, getLabel) + filterDFG!(entries, whereLabel, getLabel) return entries end function listGraphBlobentries( fg::GraphsDFG; - labelFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) labels = collect(keys(fg.graph.blobentries)) - filterDFG!(labels, labelFilter, string) + filterDFG!(labels, whereLabel, string) return labels end @@ -561,10 +561,10 @@ end function DFG.getAgentBlobentries( fg::GraphsDFG; - labelFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) entries = collect(values(fg.agent.blobentries)) - filterDFG!(entries, labelFilter, getLabel) + filterDFG!(entries, whereLabel, getLabel) return entries end diff --git a/src/services/AbstractDFG.jl b/src/services/AbstractDFG.jl index b6504f5e..f9c36fb2 100644 --- a/src/services/AbstractDFG.jl +++ b/src/services/AbstractDFG.jl @@ -315,13 +315,11 @@ function deleteFactor! end $(SIGNATURES) Get the variables in the DFG as a Vector, supporting various filters. -Arguments -- `regexFilt`: Optional Regex to filter variable labels (deprecated, use `labelFilter` instead). Keyword arguments -- `solvableFilter`: Optional function to filter on the `solvable` property, eg `>=(1)`. -- `labelFilter`: Optional function to filter on label e.g., `contains(r"x1")`. -- `tagsFilter`: Optional function to filter on tags, eg. `⊇([:POSE])`. -- `typeFilter`: Optional function to filter on the variable type. +- `whereSolvable`: Optional function to filter on the `solvable` property, eg `>=(1)`. +- `whereLabel`: Optional function to filter on label e.g., `contains(r"x1")`. +- `whereTags`: Optional function to filter on tags, eg. `⊇([:POSE])`. +- `whereType`: Optional function to filter on the variable type. Returns - `Vector{<:AbstractGraphVariable}` matching the filters. @@ -382,7 +380,7 @@ function isConnected end """ $(SIGNATURES) Retrieve a list of labels of the immediate neighbors around a given variable or factor specified by its label. -Implement `listNeighbors(dfg::AbstractDFG, label::Symbol; solvableFilter, tagsFilter)` +Implement `listNeighbors(dfg::AbstractDFG, label::Symbol; whereSolvable, whereTags)` """ function listNeighbors end @@ -398,8 +396,8 @@ provided the other defaults to all labels of that kind in `dfg`. Typical usage with filters: ```julia -vars = listVariables(dfg; solvableFilter = >=(1)) -facs = listFactors(dfg; solvableFilter = >=(1)) +vars = listVariables(dfg; whereSolvable = >=(1)) +facs = listFactors(dfg; whereSolvable = >=(1)) findPaths(dfg, :x1, :x5, 3; variableLabels = vars, factorLabels = facs) ``` @@ -494,7 +492,7 @@ end #TODO add pruning filters that is applied during traversal. """ $(SIGNATURES) -Build a list of all unique neighbors inside 'distance'. Neighbors can be filtered by using keyword arguments, eg. [`tagsFilter`] and [`solvableFilter`]. +Build a list of all unique neighbors inside 'distance'. Neighbors can be filtered by using keyword arguments, eg. [`whereTags`] and [`whereSolvable`]. Filters are applied to final neighborhood result. Notes @@ -561,24 +559,24 @@ function getSubgraph( dfg::AbstractDFG, variableFactorLabels::Vector{Symbol}, distance::Int = 0; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, graphLabel::Symbol = Symbol(getGraphLabel(dfg), "_sub_$(string(uuid4())[1:6])"), solvable = nothing, #TODO deprecated in v0.29 kwargs..., ) where {G <: AbstractDFG} if !isnothing(solvable) Base.depwarn( - "solvable kwarg is deprecated, use kwarg `solvableFilter = (>=solvable)` instead", #v0.29 + "solvable kwarg is deprecated, use kwarg `whereSolvable = (>=solvable)` instead", #v0.29 :getSubgraph, ) - !isnothing(solvableFilter) && - error("Cannot use both solvable and solvableFilter kwargs.") - solvableFilter = >=(solvable) + !isnothing(whereSolvable) && + error("Cannot use both solvable and whereSolvable kwargs.") + whereSolvable = >=(solvable) end #build up the neighborhood from variableFactorLabels variableLabels, factorLabels = - listNeighborhood(dfg, variableFactorLabels, distance; solvableFilter, tagsFilter) + listNeighborhood(dfg, variableFactorLabels, distance; whereSolvable, whereTags) # Copy the section of graph we want destDFG = deepcopyGraph(G, dfg, variableLabels, factorLabels; graphLabel, kwargs...) @@ -629,16 +627,16 @@ Notes - Returns `::NamedTuple{(:B, :varLabels, :facLabels), Tuple{SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}}}` """ function getBiadjacencyMatrix(dfg::AbstractDFG; solvable::Int = 0) - solvableFilter = >=(solvable) #FIXME solvableFilter should be kwarg - varLabels = map(v -> v.label, getVariables(dfg; solvableFilter)) - factLabels = map(f -> f.label, getFactors(dfg; solvableFilter)) + whereSolvable = >=(solvable) #FIXME whereSolvable should be kwarg + varLabels = map(v -> v.label, getVariables(dfg; whereSolvable)) + factLabels = map(f -> f.label, getFactors(dfg; whereSolvable)) vDict = Dict(varLabels .=> [1:length(varLabels)...]) adjMat = spzeros(Int, length(factLabels), length(varLabels)) for (fIndex, factLabel) in enumerate(factLabels) - factVars = listNeighbors(dfg, getFactor(dfg, factLabel); solvableFilter) + factVars = listNeighbors(dfg, getFactor(dfg, factLabel); whereSolvable) map(vLabel -> adjMat[fIndex, vDict[vLabel]] = 1, factVars) end return (B = adjMat, varLabels = varLabels, facLabels = factLabels) diff --git a/src/services/Bloblet.jl b/src/services/Bloblet.jl index 002ef744..fe2a3413 100644 --- a/src/services/Bloblet.jl +++ b/src/services/Bloblet.jl @@ -1,4 +1,4 @@ -# TODO add labelFilter to get_Bloblets +# TODO add whereLabel to get_Bloblets ## ============================================================================== ## Variable Bloblets ## ============================================================================== diff --git a/src/services/DFGVariable.jl b/src/services/DFGVariable.jl index 161c48f5..08537002 100644 --- a/src/services/DFGVariable.jl +++ b/src/services/DFGVariable.jl @@ -497,37 +497,37 @@ end $(SIGNATURES) List all the variable state labels. """ -function listStates(v::VariableDFG; labelFilter::Union{Nothing, Function} = nothing) +function listStates(v::VariableDFG; whereLabel::Union{Nothing, Function} = nothing) labels = collect(keys(v.states)) - return filterDFG!(labels, labelFilter) + return filterDFG!(labels, whereLabel) end function listStates( dfg::AbstractDFG, lbl::Symbol; - labelFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) - return listStates(getVariable(dfg, lbl); labelFilter) + return listStates(getVariable(dfg, lbl); whereLabel) end function listStates( dfg::AbstractDFG; - labelFilter::Union{Nothing, Function} = nothing, - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - variableLabelFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereVariableLabel::Union{Nothing, Function} = nothing, ) labels = Set{Symbol}() vls = listVariables( dfg; - solvableFilter, - tagsFilter, - typeFilter, - labelFilter = variableLabelFilter, + whereSolvable, + whereTags, + whereType, + whereLabel = whereVariableLabel, ) for vl in vls - union!(labels, listStates(dfg, vl; labelFilter)) + union!(labels, listStates(dfg, vl; whereLabel)) end return collect(labels) end diff --git a/src/services/find.jl b/src/services/find.jl index b3bf7cbe..43912b7e 100644 --- a/src/services/find.jl +++ b/src/services/find.jl @@ -49,14 +49,14 @@ ls, listVariables, findClosestTimestamp function findVariablesNearTimestamp( dfg::AbstractDFG, query_timestamp::TimeDateZone; - labelFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - solvableFilter::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, number::Int = 1, ) # # get the variable labels based on filters - vls = listVariables(dfg; labelFilter, tagsFilter, solvableFilter) + vls = listVariables(dfg; whereLabel, whereTags, whereSolvable) # compile timestamps with label # vars = map( x->getVariable(dfg, x), vls ) timeset = map(x -> (getTimestamp(getVariable(dfg, x)), x), vls) diff --git a/src/services/list.jl b/src/services/list.jl index 3d76ca81..27fab873 100644 --- a/src/services/list.jl +++ b/src/services/list.jl @@ -50,12 +50,12 @@ Notes: """ function ls( dfg::AbstractDFG; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - labelFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) - return listVariables(dfg; solvableFilter, tagsFilter, typeFilter, labelFilter) + return listVariables(dfg; whereSolvable, whereTags, whereType, whereLabel) end #TODO tags kwarg @@ -69,12 +69,12 @@ Notes """ function lsf( dfg::AbstractDFG; - solvableFilter::Union{Nothing, Function} = nothing, - tagsFilter::Union{Nothing, Function} = nothing, - typeFilter::Union{Nothing, Function} = nothing, - labelFilter::Union{Nothing, Function} = nothing, + whereSolvable::Union{Nothing, Function} = nothing, + whereTags::Union{Nothing, Function} = nothing, + whereType::Union{Nothing, Function} = nothing, + whereLabel::Union{Nothing, Function} = nothing, ) - return listFactors(dfg; solvableFilter, tagsFilter, typeFilter, labelFilter) + return listFactors(dfg; whereSolvable, whereTags, whereType, whereLabel) end """ @@ -100,7 +100,7 @@ end ##-------------- function ls(dfg::AbstractDFG, ::Type{T}) where {T <: StateType} - return listVariables(dfg; typeFilter = ==(T())) + return listVariables(dfg; whereType = ==(T())) end """ @@ -113,8 +113,8 @@ Notes - Return `Vector{Symbol}` """ function lsf(dfg::AbstractDFG, ::Type{T}) where {T <: AbstractObservation} - typeFilter = isconcretetype(T) ? x -> x == T : x -> x <: T - return listFactors(dfg; typeFilter) + whereType = isconcretetype(T) ? x -> x == T : x -> x <: T + return listFactors(dfg; whereType) end function ls(dfg::AbstractDFG, ::Type{T}) where {T <: AbstractObservation} @@ -148,7 +148,7 @@ Notes: - Returns `Vector{Symbol}` """ function lsfPriors(dfg::AbstractDFG) - return listFactors(dfg; typeFilter = isPrior) + return listFactors(dfg; whereType = isPrior) end ## Listing DataTypes in a DFG diff --git a/test/iifInterfaceTests.jl b/test/iifInterfaceTests.jl index 934ff02f..ab94a7e8 100644 --- a/test/iifInterfaceTests.jl +++ b/test/iifInterfaceTests.jl @@ -91,25 +91,25 @@ end @test symdiff([:a, :b], listVariables(dfg)) == [] @test listFactors(dfg) == [:abf1] # Unless we add the prior! # Additional testing for https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/201 - @test symdiff([:a, :b], listVariables(dfg; solvableFilter = >=(0))) == [] - @test listVariables(dfg; solvableFilter = >=(1)) == [:b] - @test map(v -> v.label, getVariables(dfg; solvableFilter = >=(1))) == [:b] + @test symdiff([:a, :b], listVariables(dfg; whereSolvable = >=(0))) == [] + @test listVariables(dfg; whereSolvable = >=(1)) == [:b] + @test map(v -> v.label, getVariables(dfg; whereSolvable = >=(1))) == [:b] @test listFactors(dfg) == [:abf1] - @test listFactors(dfg; solvableFilter = >=(1)) == [] - @test listFactors(dfg; solvableFilter = >=(0)) == [:abf1] - @test map(f -> f.label, getFactors(dfg; solvableFilter = >=(0))) == [:abf1] - @test map(f -> f.label, getFactors(dfg; solvableFilter = >=(1))) == [] + @test listFactors(dfg; whereSolvable = >=(1)) == [] + @test listFactors(dfg; whereSolvable = >=(0)) == [:abf1] + @test map(f -> f.label, getFactors(dfg; whereSolvable = >=(0))) == [:abf1] + @test map(f -> f.label, getFactors(dfg; whereSolvable = >=(1))) == [] # @test lsf(dfg, :a) == [f1.label] # Tags - @test ls(dfg; tagsFilter = ⊇([:POSE])) == [:a] + @test ls(dfg; whereTags = ⊇([:POSE])) == [:a] @test symdiff( - ls(dfg; tagsFilter = !isdisjoint([:POSE, :LANDMARK])), - ls(dfg; tagsFilter = ⊇([:VARIABLE])), + ls(dfg; whereTags = !isdisjoint([:POSE, :LANDMARK])), + ls(dfg; whereTags = ⊇([:VARIABLE])), ) == [] # Regexes - @test ls(dfg; labelFilter = contains(r"a")) == [v1.label] - @test lsf(dfg; labelFilter = contains(r"abf.*")) == [f1.label] + @test ls(dfg; whereLabel = contains(r"a")) == [v1.label] + @test lsf(dfg; whereLabel = contains(r"abf.*")) == [f1.label] # Accessors @test getDescription(dfg) !== nothing @@ -281,11 +281,11 @@ end @test symdiff(f_ll, [:abf1, :abf1, :abf1]) == Symbol[] # Filtered - REF DFG #201 - adjMat, v_ll, f_ll = getBiadjacencyMatrix(dfg; solvableFilter = >=(1)) + adjMat, v_ll, f_ll = getBiadjacencyMatrix(dfg; whereSolvable = >=(1)) @test size(adjMat) == (0, 1) # sparse - adjMat, v_ll, f_ll = getBiadjacencyMatrix(dfg; solvableFilter = >=(1)) + adjMat, v_ll, f_ll = getBiadjacencyMatrix(dfg; whereSolvable = >=(1)) @test size(adjMat) == (0, 1) @test issetequal(v_ll, [:b]) @test f_ll == [] @@ -339,13 +339,13 @@ facts = map( @test listNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1) # solvable checks - @test listNeighbors(dfg, :x5; solvableFilter = >=(1)) == Symbol[] - @test symdiff(listNeighbors(dfg, :x5; solvableFilter = >=(0)), [:x4x5f1, :x5x6f1]) == [] + @test listNeighbors(dfg, :x5; whereSolvable = >=(1)) == Symbol[] + @test symdiff(listNeighbors(dfg, :x5; whereSolvable = >=(0)), [:x4x5f1, :x5x6f1]) == [] @test symdiff(listNeighbors(dfg, :x5), [:x4x5f1, :x5x6f1]) == [] - @test listNeighbors(dfg, :x7x8f1; solvableFilter = >=(0)) == [:x7, :x8] - @test listNeighbors(dfg, :x7x8f1; solvableFilter = >=(1)) == [:x7] - @test listNeighbors(dfg, verts[1]; solvableFilter = >=(0)) == [:x1x2f1] - @test listNeighbors(dfg, verts[1]; solvableFilter = >=(1)) == Symbol[] + @test listNeighbors(dfg, :x7x8f1; whereSolvable = >=(0)) == [:x7, :x8] + @test listNeighbors(dfg, :x7x8f1; whereSolvable = >=(1)) == [:x7] + @test listNeighbors(dfg, verts[1]; whereSolvable = >=(0)) == [:x1x2f1] + @test listNeighbors(dfg, verts[1]; whereSolvable = >=(1)) == Symbol[] @test listNeighbors(dfg, verts[1]) == [:x1x2f1] end diff --git a/test/testBlocks.jl b/test/testBlocks.jl index 5c42104c..d9fa7f1d 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -523,7 +523,7 @@ function VariablesandFactorsCRUD_SET!(fg, v1, v2, v3, f0, f1, f2) if getVariable(fg, ls(fg)[1]) isa VariableDFG @test :default in DFG.listStates(fg) - @test :default in DFG.listStates(fg; labelFilter = contains("default") ∘ string) + @test :default in DFG.listStates(fg; whereLabel = contains("default") ∘ string) @test :default in DFG.listStates(fg) end @@ -554,8 +554,8 @@ function tagsTestBlock!(fg, v1, v1_tags) @test hasTags(fg, :b, [:LANDMARK]) @test !hasTags(fg, :b, [:LANDMARK, :TAG]) - @test listNeighbors(fg, :abf1; tagsFilter = ⊇([:LANDMARK])) == [:b] - @test isempty(listNeighbors(fg, :abf1; tagsFilter = ⊇([:LANDMARK, :TAG]))) + @test listNeighbors(fg, :abf1; whereTags = ⊇([:LANDMARK])) == [:b] + @test isempty(listNeighbors(fg, :abf1; whereTags = ⊇([:LANDMARK, :TAG]))) # Test specific type tag accessors @test issetequal(listVariableTags(fg, :a), listTags(fg, :a)) @@ -804,7 +804,7 @@ function statesExtendedTestBlock!(fg) # listStates with filters @test :default in listStates(fg, :a) - @test listStates(fg, :a; labelFilter = ==(Symbol("default")) ∘ identity) == [:default] + @test listStates(fg, :a; whereLabel = ==(Symbol("default")) ∘ identity) == [:default] # listStates across dfg returns Vector all_states = listStates(fg) @@ -1036,8 +1036,8 @@ function blobsStoresTestBlock!(fg) # test collecting blobentries with filters gathered = DFG.gatherBlobentries( fg; - variableLabelFilter = contains("a"), - labelFilter = contains("1"), + whereVariableLabel = contains("a"), + whereLabel = contains("1"), ) @test first(gathered[1]) == :a @test last(gathered[1])[1] == getVariableBlobentry(fg, :a, :label1) @@ -1164,44 +1164,44 @@ function testGroup!(fg, v1, v2, f0, f1) ## SORT copied from CRUD @test all( - getVariables(fg; labelFilter = contains(r"a")) .== [getVariable(fg, v1.label)], + getVariables(fg; whereLabel = contains(r"a")) .== [getVariable(fg, v1.label)], ) - @test all(getVariables(fg; solvableFilter = >=(1)) .== [getVariable(fg, v2.label)]) - @test getVariables(fg; labelFilter = contains(r"a"), solvableFilter = >=(1)) == [] - @test getVariables(fg; tagsFilter = ⊇([:LANDMARK]))[1] == getVariable(fg, v2.label) - - @test getFactors(fg; labelFilter = contains(r"nope")) == [] - @test issetequal(getLabel.(getFactors(fg; solvableFilter = >=(1))), [:af1, :abf1]) - @test getFactors(fg; solvableFilter = >=(2)) == [] - @test getFactors(fg; tagsFilter = ⊇([:tag1]))[1] == f1 - @test getFactors(fg; tagsFilter = ⊇([:PRIOR]))[1] == f0 + @test all(getVariables(fg; whereSolvable = >=(1)) .== [getVariable(fg, v2.label)]) + @test getVariables(fg; whereLabel = contains(r"a"), whereSolvable = >=(1)) == [] + @test getVariables(fg; whereTags = ⊇([:LANDMARK]))[1] == getVariable(fg, v2.label) + + @test getFactors(fg; whereLabel = contains(r"nope")) == [] + @test issetequal(getLabel.(getFactors(fg; whereSolvable = >=(1))), [:af1, :abf1]) + @test getFactors(fg; whereSolvable = >=(2)) == [] + @test getFactors(fg; whereTags = ⊇([:tag1]))[1] == f1 + @test getFactors(fg; whereTags = ⊇([:PRIOR]))[1] == f0 ##/SORT # Additional testing for https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/201 # list solvable - @test symdiff([:a, :b], listVariables(fg; solvableFilter = >=(0))) == [] - @test listVariables(fg; solvableFilter = >=(1)) == [:b] + @test symdiff([:a, :b], listVariables(fg; whereSolvable = >=(0))) == [] + @test listVariables(fg; whereSolvable = >=(1)) == [:b] - @test issetequal(listFactors(fg; solvableFilter = >=(1)), [:af1, :abf1]) - @test issetequal(listFactors(fg; solvableFilter = >=(0)), [:af1, :abf1]) - @test all([f in [f0, f1] for f in getFactors(fg; solvableFilter = >=(1))]) + @test issetequal(listFactors(fg; whereSolvable = >=(1)), [:af1, :abf1]) + @test issetequal(listFactors(fg; whereSolvable = >=(0)), [:af1, :abf1]) + @test all([f in [f0, f1] for f in getFactors(fg; whereSolvable = >=(1))]) @test lsf(fg, :b) == [f1.label] # Tags - @test ls(fg; tagsFilter = ⊇([:POSE])) == [] + @test ls(fg; whereTags = ⊇([:POSE])) == [] @test issetequal( - ls(fg; tagsFilter = !isdisjoint([:POSE, :LANDMARK])), - ls(fg; tagsFilter = ⊇([:VARIABLE])), + ls(fg; whereTags = !isdisjoint([:POSE, :LANDMARK])), + ls(fg; whereTags = ⊇([:VARIABLE])), ) - @test lsf(fg; tagsFilter = !isdisjoint([:NONE])) == [] - @test lsf(fg; tagsFilter = ⊇([:NONE])) == [] - @test lsf(fg; tagsFilter = ⊇([:PRIOR])) == [:af1] + @test lsf(fg; whereTags = !isdisjoint([:NONE])) == [] + @test lsf(fg; whereTags = ⊇([:NONE])) == [] + @test lsf(fg; whereTags = ⊇([:PRIOR])) == [:af1] # Regexes - @test ls(fg; labelFilter = contains(r"a")) == [v1.label] - @test lsf(fg; labelFilter = contains(r"abf*")) == [f1.label] + @test ls(fg; whereLabel = contains(r"a")) == [v1.label] + @test lsf(fg; whereLabel = contains(r"abf*")) == [f1.label] #TODO test filters and options # regexFilter::Union{Nothing, Regex}=nothing; @@ -1349,13 +1349,13 @@ function AdjacencyMatricesTestBlock(fg) # Only do solvable tests on VariableDFG if isa(getVariable(fg, :a), VariableDFG) # Filtered - REF DFG #201 - adjMat, v_ll, f_ll = getBiadjacencyMatrix(fg; solvableFilter = >=(0)) + adjMat, v_ll, f_ll = getBiadjacencyMatrix(fg; whereSolvable = >=(0)) @test size(adjMat) == (1, 3) @test symdiff(v_ll, [:a, :b, :orphan]) == Symbol[] @test symdiff(f_ll, [:abf1]) == Symbol[] # sparse - adjMat, v_ll, f_ll = getBiadjacencyMatrix(fg; solvableFilter = >=(1)) + adjMat, v_ll, f_ll = getBiadjacencyMatrix(fg; whereSolvable = >=(1)) @test size(adjMat) == (1, 2) @test issetequal(v_ll, [:a, :b]) @test f_ll == [:abf1] @@ -1448,16 +1448,16 @@ function GettingNeighbors(testDFGAPI; VARTYPE = VariableDFG, FACTYPE = FactorDFG # Solvable #TODO if not a GraphsDFG with and summary or skeleton if VARTYPE == VariableDFG - @test listNeighbors(dfg, :x5; solvableFilter = >=(2)) == Symbol[] + @test listNeighbors(dfg, :x5; whereSolvable = >=(2)) == Symbol[] @test issetequal( - listNeighbors(dfg, :x5; solvableFilter = >=(0)), + listNeighbors(dfg, :x5; whereSolvable = >=(0)), [:x4x5f1, :x5x6f1], ) @test issetequal(listNeighbors(dfg, :x5), [:x4x5f1, :x5x6f1]) - @test listNeighbors(dfg, :x7x8f1; solvableFilter = >=(0)) == [:x7, :x8] - @test listNeighbors(dfg, :x7x8f1; solvableFilter = >=(1)) == [:x7] - @test listNeighbors(dfg, verts[1]; solvableFilter = >=(0)) == [:x1x2f1] - @test listNeighbors(dfg, verts[1]; solvableFilter = >=(2)) == Symbol[] + @test listNeighbors(dfg, :x7x8f1; whereSolvable = >=(0)) == [:x7, :x8] + @test listNeighbors(dfg, :x7x8f1; whereSolvable = >=(1)) == [:x7] + @test listNeighbors(dfg, verts[1]; whereSolvable = >=(0)) == [:x1x2f1] + @test listNeighbors(dfg, verts[1]; whereSolvable = >=(2)) == Symbol[] @test listNeighbors(dfg, verts[1]) == [:x1x2f1] end end @@ -1532,7 +1532,7 @@ function BuildingSubgraphs(testDFGAPI; VARTYPE = VariableDFG, FACTYPE = FactorDF #TODO if not a GraphsDFG with and summary or skeleton if VARTYPE == VariableDFG - dfgSubgraph = getSubgraph(testDFGAPI, dfg, [:x8], 2; solvableFilter = >=(1)) + dfgSubgraph = getSubgraph(testDFGAPI, dfg, [:x8], 2; whereSolvable = >=(1)) @test issetequal([:x7], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) #end if not a GraphsDFG with and summary or skeleton end @@ -1884,7 +1884,7 @@ function PathFindingTests(testDFGAPI) # --- Restrict with variableLabels only (all factors kept) --- # Restrict to x1..x5 variables. Factors connecting only those vars are auto-included. - vars_subset = listVariables(dfg; typeFilter = ==(TestVariableType1())) + vars_subset = listVariables(dfg; whereType = ==(TestVariableType1())) result_restricted = findPath(dfg, :x1, :x5; variableLabels = vars_subset) @test first(result_restricted.path) == :x1 @test last(result_restricted.path) == :x5 @@ -1893,23 +1893,23 @@ function PathFindingTests(testDFGAPI) # --- Restrict with factorLabels only (all variables kept) --- # Only allow the first 4 factors, path x1→x5 should still work - facs_first4 = listFactors(dfg; labelFilter = contains(r"x[1-4](?!\d)")) + facs_first4 = listFactors(dfg; whereLabel = contains(r"x[1-4](?!\d)")) result_fac = findPath(dfg, :x1, :x5; factorLabels = facs_first4) @test first(result_fac.path) == :x1 @test last(result_fac.path) == :x5 # --- Restrict with both variableLabels and factorLabels --- - vars_1to5 = listVariables(dfg; typeFilter = ==(TestVariableType1())) - facs_1to4 = listFactors(dfg; labelFilter = contains(r"x[1-4](?!\d)")) + vars_1to5 = listVariables(dfg; whereType = ==(TestVariableType1())) + facs_1to4 = listFactors(dfg; whereLabel = contains(r"x[1-4](?!\d)")) result_both = findPath(dfg, :x1, :x5; variableLabels = vars_1to5, factorLabels = facs_1to4) @test first(result_both.path) == :x1 @test last(result_both.path) == :x5 - # --- With solvableFilter --- + # --- With whereSolvable --- # Only solvable >= 1 variables (excludes x8, x9) - solvable_vars = listVariables(dfg; solvableFilter = >=(1)) - solvable_facs = listFactors(dfg; solvableFilter = >=(1)) + solvable_vars = listVariables(dfg; whereSolvable = >=(1)) + solvable_facs = listFactors(dfg; whereSolvable = >=(1)) # Path from x1 to x7 should work (all solvable) result_solvable = findPath( dfg, @@ -1946,11 +1946,11 @@ function PathFindingTests(testDFGAPI) ), ) - # --- With tagsFilter --- + # --- With whereTags --- # By default all variables have :VARIABLE tag. Tag some for testing. mergeTags!(dfg, :x3, Set([:LANDMARK])) mergeTags!(dfg, :x4, Set([:LANDMARK])) - landmark_vars = listVariables(dfg; tagsFilter = ⊇([:LANDMARK])) + landmark_vars = listVariables(dfg; whereTags = ⊇([:LANDMARK])) @test :x3 ∈ landmark_vars @test :x4 ∈ landmark_vars # Restrict to only LANDMARK variables - x1 is not a LANDMARK, so include it to enable the path From 54383de7cda1f53c2ecb00e6ddb3560fff76a264 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Wed, 1 Apr 2026 11:18:09 +0200 Subject: [PATCH 2/3] fix formatting --- src/GraphsDFG/services/GraphsDFG.jl | 5 +---- test/testBlocks.jl | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/GraphsDFG/services/GraphsDFG.jl b/src/GraphsDFG/services/GraphsDFG.jl index 7cb02d5c..cbf03264 100644 --- a/src/GraphsDFG/services/GraphsDFG.jl +++ b/src/GraphsDFG/services/GraphsDFG.jl @@ -511,10 +511,7 @@ function getGraphBlobentries(fg::GraphsDFG; whereLabel::Union{Nothing, Function} return entries end -function listGraphBlobentries( - fg::GraphsDFG; - whereLabel::Union{Nothing, Function} = nothing, -) +function listGraphBlobentries(fg::GraphsDFG; whereLabel::Union{Nothing, Function} = nothing) labels = collect(keys(fg.graph.blobentries)) filterDFG!(labels, whereLabel, string) return labels diff --git a/test/testBlocks.jl b/test/testBlocks.jl index d9fa7f1d..5d4c546b 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -1449,10 +1449,7 @@ function GettingNeighbors(testDFGAPI; VARTYPE = VariableDFG, FACTYPE = FactorDFG #TODO if not a GraphsDFG with and summary or skeleton if VARTYPE == VariableDFG @test listNeighbors(dfg, :x5; whereSolvable = >=(2)) == Symbol[] - @test issetequal( - listNeighbors(dfg, :x5; whereSolvable = >=(0)), - [:x4x5f1, :x5x6f1], - ) + @test issetequal(listNeighbors(dfg, :x5; whereSolvable = >=(0)), [:x4x5f1, :x5x6f1]) @test issetequal(listNeighbors(dfg, :x5), [:x4x5f1, :x5x6f1]) @test listNeighbors(dfg, :x7x8f1; whereSolvable = >=(0)) == [:x7, :x8] @test listNeighbors(dfg, :x7x8f1; whereSolvable = >=(1)) == [:x7] From e8a52bca0fe737b3a89ac8fb8d539205693d5e2d Mon Sep 17 00:00:00 2001 From: Johannes Terblanche <6612981+Affie@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:36:25 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Johannes Terblanche <6612981+Affie@users.noreply.github.com> --- src/GraphsDFG/services/GraphsDFG.jl | 4 ++-- src/services/AbstractDFG.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GraphsDFG/services/GraphsDFG.jl b/src/GraphsDFG/services/GraphsDFG.jl index cbf03264..90d885c1 100644 --- a/src/GraphsDFG/services/GraphsDFG.jl +++ b/src/GraphsDFG/services/GraphsDFG.jl @@ -222,7 +222,7 @@ function listNeighbors( ) if !isnothing(solvable) Base.depwarn( - "solvable kwarg is deprecated, use kwarg `whereSolvable = (>=solvable)` instead", #v0.29 + "solvable kwarg is deprecated, use kwarg `whereSolvable = >=(solvable)` instead", #v0.29 :listNeighbors, ) !isnothing(whereSolvable) && @@ -261,7 +261,7 @@ function listNeighborhood( ) if !isnothing(solvable) Base.depwarn( - "solvable kwarg is deprecated, use kwarg `whereSolvable = (>=solvable)` instead", #v0.29 + "solvable kwarg is deprecated, use kwarg `whereSolvable = >=(solvable)` instead", #v0.29 :listNeighborhood, ) !isnothing(whereSolvable) && diff --git a/src/services/AbstractDFG.jl b/src/services/AbstractDFG.jl index f9c36fb2..194f46a1 100644 --- a/src/services/AbstractDFG.jl +++ b/src/services/AbstractDFG.jl @@ -567,7 +567,7 @@ function getSubgraph( ) where {G <: AbstractDFG} if !isnothing(solvable) Base.depwarn( - "solvable kwarg is deprecated, use kwarg `whereSolvable = (>=solvable)` instead", #v0.29 + "solvable kwarg is deprecated, use kwarg `whereSolvable = >=(solvable)` instead", #v0.29 :getSubgraph, ) !isnothing(whereSolvable) &&