Skip to content

Commit ba529d8

Browse files
committed
check variable order on updateFactor for LightDFG
1 parent eff0824 commit ba529d8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/LightDFG/services/LightDFG.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ function updateFactor!(dfg::LightDFG, factor::F)::F where F <: AbstractDFGFactor
123123
@warn "Factor label '$(factor.label)' does not exist in the factor graph, adding"
124124
return addFactor!(dfg, factor)
125125
end
126+
127+
# Confirm that we're not updating the neighbors
128+
dfg.g.factors[factor.label]._variableOrderSymbols != factor._variableOrderSymbols && error("Cannot update the factor, the neighbors are not the same.")
129+
126130
dfg.g.factors[factor.label] = factor
127131
return factor
128132
end

test/testBlocks.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ function VariablesandFactorsCRUD_SET!(fg, v1, v2, v3, f0, f1, f2)
394394
@test_throws ErrorException addFactor!(fg, [:b, :c], f2)
395395
#TODO Graphs.jl, but look at refactoring absract @test_throws ErrorException addFactor!(fg, f2)
396396

397+
f2_mod = deepcopy(f2)
398+
pop!(f2_mod._variableOrderSymbols)
399+
@test_throws ErrorException updateFactor!(fg, f2_mod)
400+
@test issetequal(lsf(fg), [:bcf1, :abf1])
401+
397402
@test getAddHistory(fg) == [:a, :b, :c]
398403

399404
# Extra timestamp functions https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/315
@@ -1136,7 +1141,7 @@ function BuildingSubgraphs(testDFGAPI; VARTYPE=DFGVariable, FACTYPE=DFGFactor)
11361141
end
11371142
end
11381143

1139-
#TODO buildSubgraph default constructors for skeleton and summary
1144+
#TODO buildSubgraph default constructors for skeleton and summary
11401145
if VARTYPE == DFGVariable
11411146
dfgSubgraph = buildSubgraph(dfg, [:x1, :x2, :x1x2f1])
11421147
@test issetequal([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...])

0 commit comments

Comments
 (0)