Skip to content

Commit 875caa5

Browse files
committed
Definitions completed
1 parent 1b12ad6 commit 875caa5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ JSON2
77
Graphs
88
# Caesar/IIF specific imports
99
Distributions
10+
Dates

src/services/GraphsDFG.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import Graphs: attributes, vertex_index
2222
function attributes(v::GraphsNode, g::T)::AttributeDict where T <:GenericIncidenceList
2323
AttributeDict(
2424
"label" => v.dfgNode.label,
25-
"color" => typeof(v.dfgNode) == DFGVariable ? "red" : "blue",
26-
"shape" => typeof(v.dfgNode) == DFGVariable ? "box" : "ellipse",
27-
"fillcolor" => typeof(v.dfgNode) == DFGVariable ? "red" : "blue"
25+
"color" => v.dfgNode isa DFGVariable ? "red" : "blue",
26+
"shape" => v.dfgNode isa DFGVariable ? "box" : "ellipse",
27+
"fillcolor" => v.dfgNode isa DFGVariable ? "red" : "blue"
2828
)
2929
end
3030

@@ -226,7 +226,7 @@ List the DFGVariables in the DFG.
226226
Optionally specify a label regular expression to retrieves a subset of the variables.
227227
"""
228228
function ls(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGVariable}
229-
variables = map(v -> v.dfgNode, filter(n -> typeof(n.dfgNode) == DFGVariable, collect(values(dfg.g.vertices))))
229+
variables = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGVariable, vertices(dfg.g)))
230230
if regexFilter != nothing
231231
variables = filter(v -> occursin(regexFilter, String(v.label)), variables)
232232
end
@@ -247,7 +247,7 @@ List the DFGFactors in the DFG.
247247
Optionally specify a label regular expression to retrieves a subset of the factors.
248248
"""
249249
function lsf(dfg::GraphsDFG, regexFilter::Union{Nothing, Regex}=nothing)::Vector{DFGFactor}
250-
factors = map(v -> v.dfgNode, filter(n -> typeof(n.dfgNode) == DFGFactor, collect(values(dfg.g.vertices))))
250+
factors = map(v -> v.dfgNode, filter(n -> n.dfgNode isa DFGFactor, vertices(dfg.g)))
251251
if regexFilter != nothing
252252
factors = filter(f -> occursin(regexFilter, String(f.label)), factors)
253253
end
@@ -321,8 +321,8 @@ end
321321
function _copyIntoGraph!(sourceDFG::GraphsDFG, destDFG::GraphsDFG, variableFactorLabels::Vector{Symbol}, includeOrphanFactors::Bool=false)::Nothing
322322
# Split into variables and factors
323323
verts = map(id -> sourceDFG.g.vertices[sourceDFG.labelDict[id]], variableFactorLabels)
324-
sourceVariables = filter(n -> typeof(n.dfgNode) == DFGVariable, verts)
325-
sourceFactors = filter(n -> typeof(n.dfgNode) == DFGFactor, verts)
324+
sourceVariables = filter(n -> n.dfgNode isa DFGVariable, verts)
325+
sourceFactors = filter(n -> n.dfgNode isa DFGFactor, verts)
326326

327327
# Now we have to add all variables first,
328328
for variable in sourceVariables

test/interfaceTests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ f1 = DFGFactor{Int, :Symbol}(:f1)
88
@test_throws Exception addVariable!(dfg, v1)
99
addVariable!(dfg, v2)
1010
addFactor!(dfg, [v1, v2], f1)
11-
@test_throws Exception addFactor!(dfg, DFGFactor("f2"), [v1, DFGVariable("Nope")])
11+
@test_throws Exception addFactor!(dfg, DFGFactor{Int, :Symbol}("f2"), [v1, DFGVariable("Nope")])
1212
end
1313

1414
@testset "Listing Nodes" begin
@@ -71,7 +71,7 @@ numNodes = 10
7171
dfg = testDFGAPI()
7272
verts = map(n -> DFGVariable(Symbol("x$n")), 1:numNodes)
7373
map(v -> addVariable!(dfg, v), verts)
74-
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
74+
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor{Int, :Symbol}(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
7575
# map(n -> addFactor!(dfg, [verts[n], verts[n+2]], DFGFactor(Symbol("x$(n)x$(n+2)f2"))), 1:2:(numNodes-2))
7676

7777
@testset "Getting Neighbors" begin

0 commit comments

Comments
 (0)