Skip to content

Commit

Permalink
Merge pull request #610 from JuliaRobotics/hotfix/3Q20/608
Browse files Browse the repository at this point in the history
add filters for listSolveKeys
  • Loading branch information
dehann authored Aug 14, 2020
2 parents f145c5b + 5e9f8b7 commit ff27aa4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
29 changes: 24 additions & 5 deletions src/services/AbstractDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,23 @@ listVariables(dfg, r"l", tags=[:APRILTAG;])
Related:
- ls
"""
function listVariables(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0) where G <: AbstractDFG
function listVariables(dfg::AbstractDFG,
regexFilter::Union{Nothing, Regex}=nothing;
tags::Vector{Symbol}=Symbol[],
solvable::Int=0 )
#
vars = getVariables(dfg, regexFilter, tags=tags, solvable=solvable)
return map(v -> v.label, vars)
return map(v -> v.label, vars)::Vector{Symbol}
end

# to be consolidated, see #612
function listVariables(dfg::AbstractDFG,
typeFilter::Type{<:InferenceVariable};
tags::Vector{Symbol}=Symbol[],
solvable::Int=0 )
#
retlist::Vector{Symbol} = ls(dfg, typeFilter)
0 < length(tags) || solvable != 0 ? intersect(retlist, ls(dfg, tags=tags, solvable=solvable)) : retlist
end

"""
Expand All @@ -495,7 +509,7 @@ Get a list of the IDs (labels) of the DFGFactors in the DFG.
Optionally specify a label regular expression to retrieves a subset of the factors.
"""
function listFactors(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0)::Vector{Symbol} where G <: AbstractDFG
return map(f -> f.label, getFactors(dfg, regexFilter, tags=tags, solvable=solvable))
return map(f -> f.label, getFactors(dfg, regexFilter, tags=tags, solvable=solvable))
end

"""
Expand All @@ -506,9 +520,14 @@ Related
listSupersolves, getSolverDataDict, listVariables
"""
function listSolveKeys(dfg::AbstractDFG)
function listSolveKeys(dfg::AbstractDFG,
fltr::Union{Type{<:InferenceVariable},Regex, Nothing}=nothing;
tags::Vector{Symbol}=Symbol[],
solvable::Int=0 )
#
skeys = Set{Symbol}()
for vs in listVariables(dfg), ky in keys(getSolverDataDict(getVariable(dfg, vs)))
varList = listVariables(dfg, fltr, tags=tags, solvable=solvable)
for vs in varList, ky in keys(getSolverDataDict(getVariable(dfg, vs)))
push!(skeys, ky)
end
return skeys
Expand Down
9 changes: 4 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ if get(ENV, "IIF_TEST", "") == "true"

using IncrementalInference

apis = [
# GraphsDFG{SolverParams}(),
LightDFG(solverParams=SolverParams(), userId="testUserId"),
CloudGraphsDFG(solverParams=SolverParams(), userId="testUserId")
]
apis = [LightDFG(solverParams=SolverParams(), userId="testUserId")]
haskey(ENV, "SKIP_CGDFG_TESTS") && ENV["SKIP_CGDFG_TESTS"] != "true" ? push!(apis, CloudGraphsDFG(solverParams=SolverParams(), userId="testUserId") ) : nothing
# GraphsDFG{SolverParams}()

for api in apis
@testset "Testing Driver: $(typeof(api))" begin
@info "Testing Driver: $(api)"
Expand Down

0 comments on commit ff27aa4

Please sign in to comment.