Skip to content

Commit 274f156

Browse files
committed
Getting more tests to work
1 parent 57d11f2 commit 274f156

File tree

3 files changed

+39
-31
lines changed

3 files changed

+39
-31
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,15 @@ deleteFactor!(dfg::CloudGraphsDFG, factor::DFGFactor)::DFGFactor = deleteFactor!
544544
List the DFGVariables in the DFG.
545545
Optionally specify a label regular expression to retrieves a subset of the variables.
546546
"""
547-
function getVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable}
547+
function getVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
548548
variableIds = getVariableIds(dfg, regexFilter)
549-
return map(vId->getVariable(dfg, vId), variableIds)
549+
# TODO: Optimize to use tags in query here!
550+
variables = map(vId->getVariable(dfg, vId), variableIds)
551+
if length(tags) > 0
552+
mask = map(v -> length(intersect(v.tags, tags)) > 0, variables )
553+
return variables[mask]
554+
end
555+
return variables
550556
end
551557

552558
"""

test/iifInterfaceTests.jl

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,36 @@ global dfg,v1,v2,f1
4545
@test lsf(dfg2) == [:v1v2f1]
4646
end
4747

48-
# @testset "Listing Nodes" begin
49-
# global dfg,v1,v2,f1
50-
# @test length(ls(dfg)) == 2
51-
# @test length(lsf(dfg)) == 1
52-
# @test symdiff([:a, :b], getVariableIds(dfg)) == []
53-
# @test getFactorIds(dfg) == [:abf1]
54-
# #
55-
# @test lsf(dfg, :a) == [f1.label]
56-
# # Tags
57-
# @test ls(dfg, tags=[:POSE]) == [:a]
58-
# @test symdiff(ls(dfg, tags=[:POSE, :LANDMARK]), ls(dfg, tags=[:VARIABLE])) == []
59-
# # Regexes
60-
# @test ls(dfg, r"a") == [v1.label]
61-
# @test lsf(dfg, r"f*") == [f1.label]
62-
# # Accessors
63-
# @test getAddHistory(dfg) == [:a, :b] #, :abf1
64-
# @test getDescription(dfg) != nothing
65-
# @test getLabelDict(dfg) != nothing
66-
# # Existence
67-
# @test exists(dfg, :a) == true
68-
# @test exists(dfg, v1) == true
69-
# @test exists(dfg, :nope) == false
70-
# # Sorting of results
71-
# # TODO - this function needs to be cleaned up
72-
# unsorted = [:x1_3;:x1_6;:l1;:april1] #this will not work for :x1x2f1
73-
# @test sortDFG(unsorted) == sortVarNested(unsorted)
74-
# @test_skip sortDFG([:x1x2f1, :x1l1f1]) == [:x1l1f1, :x1x2f1]
75-
# end
48+
@testset "Listing Nodes" begin
49+
global dfg,v1,v2,f1
50+
@test length(ls(dfg)) == 2
51+
@test length(lsf(dfg)) == 1 # Unless we add the prior!
52+
@test symdiff([:v1, :v2], getVariableIds(dfg)) == []
53+
@test getFactorIds(dfg) == [:v1v2f1] # Unless we add the prior!
54+
#
55+
@test lsf(dfg, :v1) == [f1.label]
56+
# Tags
57+
@test ls(dfg, tags=[:POSE]) == [:v1]
58+
@test symdiff(ls(dfg, tags=[:POSE, :LANDMARK]), ls(dfg, tags=[:VARIABLE])) == []
59+
# Regexes
60+
@test ls(dfg, r"v1") == [v1.label]
61+
# TODO: Check that this regular expression works on everything else!
62+
# REF: https://stackoverflow.com/questions/23834692/using-regular-expression-in-neo4j
63+
@test lsf(dfg, r"v1v2.*") == [f1.label]
64+
# Accessors
65+
@test getAddHistory(dfg) == [:v1, :v2] #, :abf1
66+
@test getDescription(dfg) != nothing
67+
@test getLabelDict(dfg) != nothing
68+
# Existence
69+
@test exists(dfg, :v1) == true
70+
@test exists(dfg, v1) == true
71+
@test exists(dfg, :nope) == false
72+
# Sorting of results
73+
# TODO - this function needs to be cleaned up
74+
unsorted = [:x1_3;:x1_6;:l1;:april1] #this will not work for :x1x2f1
75+
@test sortDFG(unsorted) == sortVarNested(unsorted)
76+
@test_skip sortDFG([:x1x2f1, :x1l1f1]) == [:x1l1f1, :x1x2f1]
77+
end
7678
#
7779
# # Gets
7880
# @testset "Gets, Sets, and Accessors" begin

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using IncrementalInference
88
# Can do duplicates with different parameters.
99
apis = [
1010
# GraphsDFG{NoSolverParams}(),
11-
# LightDFG{NoSolverParams}(),
11+
LightDFG{NoSolverParams}(),
1212
# MetaGraphsDFG{NoSolverParams}(),
1313
# SymbolDFG{NoSolverParams}(),
1414
CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test",

0 commit comments

Comments
 (0)