Skip to content

Commit a3f213d

Browse files
committed
fix #375
1 parent efdc701 commit a3f213d

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

src/Deprecated.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ Base.getproperty(x::DFGFactor,f::Symbol) = begin
3838
elseif f == :_internalId
3939
getfield(x,:_dfgNodeParams)._internalId
4040
elseif f == :data
41-
42-
if !(@isdefined getFactorDataWarnOnce)
43-
@warn "get: data field is deprecated, use getSolverData. Further warnings are suppressed"
44-
global getFactorDataWarnOnce = true
45-
end
46-
41+
Base.depwarn("DFGFactor get: data field is deprecated, use getSolverData", :getproperty)
4742
getfield(x, :solverData)
4843
else
4944
getfield(x,f)
@@ -57,12 +52,7 @@ Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
5752
elseif f == :_internalId
5853
getfield(x,:_dfgNodeParams)._internalId = val
5954
elseif f == :data
60-
61-
if !(@isdefined setFactorDataWarnOnce)
62-
@warn "set: data field is deprecated, use ...TODO? Further warnings are suppressed"
63-
global setFactorDataWarnOnce = true
64-
end
65-
55+
Base.depwarn("DFGFactor set: data field is deprecated, use getSolverData", :getproperty)
6656
setfield!(x,:solverData, val)
6757
else
6858
setfield!(x,f,val)

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ function getVariable(dfg::GraphsDFG, label::Union{Symbol, String})::DFGVariable
121121
if !haskey(dfg.labelDict, label)
122122
error("Variable label '$(label)' does not exist in the factor graph")
123123
end
124-
return dfg.g.vertices[dfg.labelDict[label]].dfgNode
124+
node = dfg.g.vertices[dfg.labelDict[label]].dfgNode
125+
!isa(node, AbstractDFGVariable) && error("Node with label '$(label)' is not a variable")
126+
return node
125127
end
126128

127129
function getFactor(dfg::GraphsDFG, factorId::Int64)::DFGFactor
@@ -140,7 +142,9 @@ function getFactor(dfg::GraphsDFG, label::Union{Symbol, String})::DFGFactor
140142
if !haskey(dfg.labelDict, label)
141143
error("Factor label '$(label)' does not exist in the factor graph")
142144
end
143-
return dfg.g.vertices[dfg.labelDict[label]].dfgNode
145+
node = dfg.g.vertices[dfg.labelDict[label]].dfgNode
146+
!isa(node, AbstractDFGFactor) && error("Node with label '$(label)' is not a factor")
147+
return node
144148
end
145149

146150
function updateVariable!(dfg::GraphsDFG, variable::DFGVariable)::DFGVariable

test/testBlocks.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ struct TestFunctorSingleton <: FunctorSingleton end
2424
struct TestFunctorPairwise <: FunctorPairwise end
2525
struct TestFunctorPairwiseMinimize <: FunctorPairwiseMinimize end
2626

27+
struct PackedTestFunctorInferenceType1 end
28+
Base.convert(::Type{GenericFunctionNodeData{PackedTestFunctorInferenceType1,AbstractString}}, d) = d
29+
2730
struct TestCCW{T} <: ConvolutionObject where {T<:FunctorInferenceType}
2831
usrfnc!::T
2932
end
@@ -338,7 +341,7 @@ function VariablesandFactorsCRUD_SET!(fg, v1, v2, v3, f0, f1, f2)
338341
#deletions
339342
@test getVariable(fg, :c) === deleteVariable!(fg, v3)
340343
@test_throws ErrorException deleteVariable!(fg, v3)
341-
@test setdiff(ls(fg),[:a,:b]) == []
344+
@test issetequal(ls(fg),[:a,:b])
342345
@test getFactor(fg, :bcf1) === deleteFactor!(fg, f2)
343346
@test_throws ErrorException deleteFactor!(fg, f2)
344347
@test lsf(fg) == [:abf1]
@@ -356,14 +359,14 @@ function VariablesandFactorsCRUD_SET!(fg, v1, v2, v3, f0, f1, f2)
356359
@test_logs (:warn, r"supported for type DFGVariable") getVariable(fg, :a, :missingfoo)
357360
end
358361

359-
@test getFactor(fg, :abf1) === f1
362+
@test getFactor(fg, :abf1) == f1
360363

361364
@test_throws ErrorException getVariable(fg, :c)
362365
@test_throws ErrorException getFactor(fg, :bcf1)
363366

364367
#test issue #375
365-
@test_skip @test_throws ErrorException getVariable(fg, :abf1)
366-
@test_skip @test_throws ErrorException getFactor(fg, :a)
368+
@test_throws ErrorException getVariable(fg, :abf1)
369+
@test_throws ErrorException getFactor(fg, :a)
367370

368371
# Existence
369372
@test exists(fg, :a)

0 commit comments

Comments
 (0)