Skip to content

Commit 17cbca5

Browse files
committed
Merge branch 'master' of https://github.com/JuliaRobotics/DistributedFactorGraphs.jl into feature/cloudgraphdfg
2 parents ef4cdd0 + 9f0834d commit 17cbca5

File tree

6 files changed

+64
-64
lines changed

6 files changed

+64
-64
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.1.3"
3+
version = "0.2.0"
44

55
[deps]
66
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function _getname(t::T) where T
1212
T.name.name
1313
end
1414

15-
# Simply for convenience -don't export
15+
# Simply for convenience - don't export
1616
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T, <: AbstractString}
1717
PackedFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, x7::String="", x8::Vector{Int}=Int[]) where {T <: PackedInferenceType, S <: AbstractString} = GenericFunctionNodeData(x1, x2, x3, x4, x5, x6, x7, x8)
1818
const FunctionNodeData{T} = GenericFunctionNodeData{T, Symbol}
@@ -544,26 +544,16 @@ Delete the referened DFGFactor from the DFG.
544544
"""
545545
deleteFactor!(dfg::CloudGraphsDFG, factor::DFGFactor)::DFGFactor = deleteFactor!(dfg, factor.label)
546546

547-
# Returns a flat vector of the vertices, keyed by ID.
548-
# Assuming only variables here for now - think maybe not, should be variables+factors?
549547
"""
550548
$(SIGNATURES)
551549
List the DFGVariables in the DFG.
552550
Optionally specify a label regular expression to retrieves a subset of the variables.
553551
"""
554-
function ls(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable}
552+
function getVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable}
555553
variableIds = getVariableIds(dfg, regexFilter)
556554
return map(vId->getVariable(dfg, vId), variableIds)
557555
end
558556

559-
# Alias
560-
"""
561-
$(SIGNATURES)
562-
List the DFGVariables in the DFG.
563-
Optionally specify a label regular expression to retrieves a subset of the variables.
564-
"""
565-
getVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable} = ls(dfg, regexFilter)
566-
567557
"""
568558
$(SIGNATURES)
569559
Get a list of IDs of the DFGVariables in the DFG.
@@ -578,32 +568,22 @@ function getVariableIds(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=
578568
end
579569
end
580570

571+
# Alias
581572
"""
582573
$(SIGNATURES)
583-
List the DFGFactors in the DFG.
584-
Optionally specify a label regular expression to retrieves a subset of the factors.
574+
List the DFGVariables in the DFG.
575+
Optionally specify a label regular expression to retrieves a subset of the variables.
585576
"""
586-
function lsf(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
587-
factorIds = getFactorIds(dfg, regexFilter)
588-
return map(vId->getFactor(dfg, vId), factorIds)
589-
end
577+
ls(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = getVariableIds(dfg, regexFilter)
590578

591-
# Alias
592579
"""
593580
$(SIGNATURES)
594581
List the DFGFactors in the DFG.
595582
Optionally specify a label regular expression to retrieves a subset of the factors.
596583
"""
597-
getFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor} = lsf(dfg, regexFilter)
598-
599-
# Alias - getNeighbors
600-
#TODO: Refactor this
601-
"""
602-
$(SIGNATURES)
603-
Get neighbors around a given node. TODO: Refactor this
604-
"""
605-
function lsf(dfg::CloudGraphsDFG, label::Symbol)::Vector{Symbol}
606-
return getNeighbors(dfg, label)
584+
function getFactors(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
585+
factorIds = getFactorIds(dfg, regexFilter)
586+
return map(vId->getFactor(dfg, vId), factorIds)
607587
end
608588

609589
"""
@@ -620,6 +600,23 @@ function getFactorIds(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=no
620600
end
621601
end
622602

603+
# Alias
604+
"""
605+
$(SIGNATURES)
606+
List the DFGFactors in the DFG.
607+
Optionally specify a label regular expression to retrieves a subset of the factors.
608+
"""
609+
lsf(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = getFactorIds(dfg, regexFilter)
610+
611+
# Alias - getNeighbors
612+
"""
613+
$(SIGNATURES)
614+
Get neighbors around a given node. TODO: Refactor this
615+
"""
616+
function lsf(dfg::CloudGraphsDFG, label::Symbol)::Vector{Symbol}
617+
return getNeighbors(dfg, label)
618+
end
619+
623620
"""
624621
$(SIGNATURES)
625622
Checks if the graph is fully connected, returns true if so.

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,12 @@ Delete the referened DFGFactor from the DFG.
218218
"""
219219
deleteFactor!(dfg::GraphsDFG, factor::DFGFactor)::DFGFactor = deleteFactor!(dfg, factor.label)
220220

221-
# # Returns a flat vector of the vertices, keyed by ID.
222-
# # Assuming only variables here for now - think maybe not, should be variables+factors?
223221
"""
224222
$(SIGNATURES)
225223
List the DFGVariables in the DFG.
226224
Optionally specify a label regular expression to retrieves a subset of the variables.
227225
"""
228-
function ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
226+
function getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
229227
variables = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGVariable, vertices(dfg.g)))
230228
if regexFilter != nothing
231229
variables = filter(v -> occursin(regexFilter, String(v.label)), variables)
@@ -237,14 +235,6 @@ function ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Ve
237235
return variables
238236
end
239237

240-
# Alias
241-
"""
242-
$(SIGNATURES)
243-
List the DFGVariables in the DFG.
244-
Optionally specify a label regular expression to retrieves a subset of the variables.
245-
"""
246-
getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable} = ls(dfg, regexFilter, tags=tags)
247-
248238
"""
249239
$(SIGNATURES)
250240
Get a list of IDs of the DFGVariables in the DFG.
@@ -260,42 +250,54 @@ Related
260250
ls
261251
"""
262252
function getVariableIds(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{Symbol}
263-
vars = ls(dfg, regexFilter, tags=tags)
253+
vars = getVariables(dfg, regexFilter, tags=tags)
264254
# mask = map(v -> length(intersect(v.tags, tags)) > 0, vars )
265255
map(v -> v.label, vars)
266256
end
267257

258+
# Alias
259+
"""
260+
$(SIGNATURES)
261+
List the DFGVariables in the DFG.
262+
Optionally specify a label regular expression to retrieves a subset of the variables.
263+
"""
264+
ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{Symbol} = getVariableIds(dfg, regexFilter, tags=tags)
268265

269266
"""
270267
$(SIGNATURES)
271268
List the DFGFactors in the DFG.
272269
Optionally specify a label regular expression to retrieves a subset of the factors.
273270
"""
274-
function lsf(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
275-
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
276-
if regexFilter != nothing
277-
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
278-
end
279-
return factors
280-
end
281-
function lsf(dfg::GraphsDFG, label::Symbol)::Vector{Symbol}
282-
return getNeighbors(dfg, label)
271+
function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
272+
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
273+
if regexFilter != nothing
274+
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
275+
end
276+
return factors
283277
end
284278

285-
# Alias
286279
"""
287280
$(SIGNATURES)
288-
List the DFGFactors in the DFG.
281+
Get a list of the IDs of the DFGFactors in the DFG.
289282
Optionally specify a label regular expression to retrieves a subset of the factors.
290283
"""
291-
getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor} = lsf(dfg, regexFilter)
284+
getFactorIds(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = map(f -> f.label, getFactors(dfg, regexFilter))
292285

293286
"""
294287
$(SIGNATURES)
295-
Get a list of the IDs of the DFGFactors in the DFG.
288+
List the DFGFactors in the DFG.
296289
Optionally specify a label regular expression to retrieves a subset of the factors.
297290
"""
298-
getFactorIds(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = map(f -> f.label, lsf(dfg, regexFilter))
291+
# Alias
292+
lsf(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = getFactorIds(dfg, regexFilter)
293+
294+
"""
295+
$(SIGNATURES)
296+
Alias for getNeighbors - returns neighbors around a given node label.
297+
"""
298+
function lsf(dfg::GraphsDFG, label::Symbol)::Vector{Symbol}
299+
return getNeighbors(dfg, label)
300+
end
299301

300302
"""
301303
$(SIGNATURES)

test/cloudGraphsDFGTests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Run: sudo docker run --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=neo4j/test neo4j
77

88
using Revise
9+
using Neo4j
910
using DistributedFactorGraphs
1011
using IncrementalInference
1112
using Test
@@ -92,12 +93,12 @@ end
9293
# Not fast though, TODO: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/39
9394
vars = getVariables(cgDFG)
9495
vars2 = ls(cgDFG)
95-
@test map(v->v.label, vars) == map(v->v.label, vars2)
96+
@test map(v->v.label, vars) == vars2
9697
@test symdiff(map(v->v.label, vars), [:x1, :x2, :x3, :l1, :l2]) == []
9798

9899
facts = getFactors(cgDFG)
99100
facts2 = lsf(cgDFG)
100-
@test map(v->v.label, facts) == map(v->v.label, facts2)
101+
@test map(v->v.label, facts) == facts2
101102
@test symdiff(map(f->f.label, facts), [:x1x2f1, :x1f1, :x2l1f1, :x2x3f1, :x3l2f1, :x1l1f1]) == []
102103

103104
@test symdiff(getNeighbors(cgDFG, :x2), [:x2l1f1, :x2x3f1, :x1x2f1]) == []

test/interfaceTests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ addFactor!(dfg, [v1, v2], f1)
1717
@test symdiff([:a, :b], getVariableIds(dfg)) == []
1818
@test getFactorIds(dfg) == [:f1]
1919
# Regexes
20-
@test ls(dfg, r"a") == [v1]
21-
@test lsf(dfg, r"f*") == [f1]
20+
@test ls(dfg, r"a") == [v1.label]
21+
@test lsf(dfg, r"f*") == [f1.label]
2222
# Accessors
2323
@test getAddHistory(dfg) == [:a, :b] #, :f1
2424
@test getDescription(dfg) != nothing
@@ -118,13 +118,13 @@ end
118118
# Subgraphs
119119
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2)
120120
# Only returns x1 and x2
121-
@test symdiff([:x1, :x1x2f1, :x2], map(n -> n.label, [ls(dfgSubgraph)..., lsf(dfgSubgraph)...])) == []
121+
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
122122
# Test include orphan factorsVoid
123123
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 1, true)
124-
@test symdiff([:x1, :x1x2f1], map(n -> n.label, [ls(dfgSubgraph)..., lsf(dfgSubgraph)...])) == []
124+
@test symdiff([:x1, :x1x2f1], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
125125
# Test adding to the dfg
126126
dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2, true, dfgSubgraph)
127-
@test symdiff([:x1, :x1x2f1, :x2], map(n -> n.label, [ls(dfgSubgraph)..., lsf(dfgSubgraph)...])) == []
127+
@test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == []
128128
end
129129

130130
@testset "Producing Dot Files" begin

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using DistributedFactorGraphs
66
apis = [GraphsDFG]
77
# apis = [graphsDFG, cgDFG]
88
for api in apis
9-
@testset "Testing Driver: $(typeof(api))" begin
9+
@testset "Testing Driver: $(api)" begin
1010
global testDFGAPI = api
1111
include("interfaceTests.jl")
1212
end

0 commit comments

Comments
 (0)