Skip to content

Commit 1d06981

Browse files
committed
Fixing Graphsjl driver
1 parent 0b182a2 commit 1d06981

File tree

4 files changed

+35
-33
lines changed

4 files changed

+35
-33
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
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}

src/GraphsDFG/services/GraphsDFG.jl

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

212-
# # Returns a flat vector of the vertices, keyed by ID.
213-
# # Assuming only variables here for now - think maybe not, should be variables+factors?
214212
"""
215213
$(SIGNATURES)
216214
List the DFGVariables in the DFG.
217215
Optionally specify a label regular expression to retrieves a subset of the variables.
218216
"""
219-
function ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
217+
function getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable}
220218
variables = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGVariable, vertices(dfg.g)))
221219
if regexFilter != nothing
222220
variables = filter(v -> occursin(regexFilter, String(v.label)), variables)
@@ -228,14 +226,6 @@ function ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Ve
228226
return variables
229227
end
230228

231-
# Alias
232-
"""
233-
$(SIGNATURES)
234-
List the DFGVariables in the DFG.
235-
Optionally specify a label regular expression to retrieves a subset of the variables.
236-
"""
237-
getVariables(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{DFGVariable} = ls(dfg, regexFilter, tags=tags)
238-
239229
"""
240230
$(SIGNATURES)
241231
Get a list of IDs of the DFGVariables in the DFG.
@@ -251,42 +241,54 @@ Related
251241
ls
252242
"""
253243
function getVariableIds(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{Symbol}
254-
vars = ls(dfg, regexFilter, tags=tags)
244+
vars = getVariables(dfg, regexFilter, tags=tags)
255245
# mask = map(v -> length(intersect(v.tags, tags)) > 0, vars )
256246
map(v -> v.label, vars)
257247
end
258248

249+
# Alias
250+
"""
251+
$(SIGNATURES)
252+
List the DFGVariables in the DFG.
253+
Optionally specify a label regular expression to retrieves a subset of the variables.
254+
"""
255+
ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[])::Vector{Symbol} = getVariableIds(dfg, regexFilter, tags=tags)
259256

260257
"""
261258
$(SIGNATURES)
262259
List the DFGFactors in the DFG.
263260
Optionally specify a label regular expression to retrieves a subset of the factors.
264261
"""
265-
function lsf(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
266-
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
267-
if regexFilter != nothing
268-
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
269-
end
270-
return factors
271-
end
272-
function lsf(dfg::GraphsDFG, label::Symbol)::Vector{Symbol}
273-
return getNeighbors(dfg, label)
262+
function getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
263+
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
264+
if regexFilter != nothing
265+
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
266+
end
267+
return factors
274268
end
275269

276-
# Alias
277270
"""
278271
$(SIGNATURES)
279-
List the DFGFactors in the DFG.
272+
Get a list of the IDs of the DFGFactors in the DFG.
280273
Optionally specify a label regular expression to retrieves a subset of the factors.
281274
"""
282-
getFactors(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor} = lsf(dfg, regexFilter)
275+
getFactorIds(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = map(f -> f.label, getFactors(dfg, regexFilter))
283276

284277
"""
285278
$(SIGNATURES)
286-
Get a list of the IDs of the DFGFactors in the DFG.
279+
List the DFGFactors in the DFG.
287280
Optionally specify a label regular expression to retrieves a subset of the factors.
288281
"""
289-
getFactorIds(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = map(f -> f.label, lsf(dfg, regexFilter))
282+
# Alias
283+
lsf(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{Symbol} = getFactorIds(dfg, regexFilter)
284+
285+
"""
286+
$(SIGNATURES)
287+
Alias for getNeighbors - returns neighbors around a given node label.
288+
"""
289+
function lsf(dfg::GraphsDFG, label::Symbol)::Vector{Symbol}
290+
return getNeighbors(dfg, label)
291+
end
290292

291293
"""
292294
$(SIGNATURES)

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)