Skip to content

Commit 7be096f

Browse files
committed
tests passing and better api
1 parent 8baa707 commit 7be096f

File tree

9 files changed

+36
-33
lines changed

9 files changed

+36
-33
lines changed

docs/src/GraphData.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Example of PPE operations:
111111
# Add a new PPE of type MeanMaxPPE to :x0
112112
ppe = MeanMaxPPE(:default, [0.0], [0.0], [0.0])
113113
addPPE!(dfg, :x0, ppe)
114-
@show listPPE(dfg, :x0)
114+
@show listPPEs(dfg, :x0)
115115
# Get the data back - note that this is a reference to above.
116116
v = getPPE(dfg, :x0, :default)
117117
# Delete it

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function getVariable(dfg::CloudGraphsDFG, label::Union{Symbol, String})::DFGVari
181181
variable = unpackVariable(dfg, props)
182182

183183
# TODO - make this get PPE's in batch
184-
for ppe in listPPE(dfg, label)
184+
for ppe in listPPEs(dfg, label)
185185
variable.ppeDict[ppe] = getPPE(dfg, label, ppe)
186186
end
187187
return variable
@@ -441,7 +441,7 @@ end
441441

442442
### PPEs with DB calls
443443

444-
function listPPE(dfg::CloudGraphsDFG, variablekey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::Vector{Symbol}
444+
function listPPEs(dfg::CloudGraphsDFG, variablekey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::Vector{Symbol}
445445
query = "match (ppe:$(join(_getLabelsForType(dfg, MeanMaxPPE, parentKey=variablekey),':'))) return ppe.solverKey"
446446
@debug "[Query] PPE read query:\r\n$query"
447447
result = nothing
@@ -475,7 +475,7 @@ function getPPE(dfg::CloudGraphsDFG, variablekey::Symbol, ppekey::Symbol=:defaul
475475
end
476476

477477
function addPPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::AbstractPointParametricEst where P <: AbstractPointParametricEst
478-
if ppekey in listPPE(dfg, variablekey, currentTransaction=currentTransaction)
478+
if ppekey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction)
479479
error("PPE '$(ppekey)' already exists")
480480
end
481481
return updatePPE!(dfg, variablekey, ppe, ppekey, currentTransaction=currentTransaction)

src/Deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@deprecate getFactorIds(dfg, regexFilter=nothing; solvable=0) listFactors(dfg, regexFilter, solvable=solvable)
1414

15+
@deprecate listPPE(args...) listPPEs(args...)
1516

1617
export getLabelDict
1718
getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,15 @@ export getMaxPPE, getMeanPPE, getSuggestedPPE, getLastUpdatedTimestamp
141141

142142
# accessors
143143

144-
export getPPEDict
144+
export getPPEDict, getVariablePPEDict, getVariablePPE
145145

146146
# CRUD & SET
147147
export getPPE,
148-
getPPEs,
149148
getVariablePPE,
150-
getVariablePPEs,
151149
addPPE!,
152150
updatePPE!,
153151
deletePPE!,
154-
listPPE,
152+
listPPEs,
155153
mergePPEs! #TODO look at rename to just mergePPE to match with cloud?
156154

157155

src/needsahome.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ printVariable(dfg::AbstractDFG, sym::Symbol, solveKey::Symbol=:default) = print(
104104
print(dfg::AbstractDFG, sym::Symbol) = isVariable(dfg,sym) ? printVariable(dfg, sym) : printFactor(dfg, sym)
105105

106106

107-
#NOT too many aliases on PPE, brought back from deprecated DF
108-
109-
getVariablePPEDict(vari::VariableDataLevel1) = getPPEDict(vari)
110-
111-
getPPEDict(vari::VariableDataLevel1) = getPPEDict(vari)
112-
113-
getVariablePPE(args...) = getPPE(args...)
114107

115108
## KEEPING COMMENT, WANT TO BE CONSOLIDATED WITH FUNCTION ABOVE -- KEEPING ONLY ONE FOR MAINTAINABILITY
116109
## STILL NEEDS TO BE CONSOLIDATED WITH `DFG._copyIntoGraph`

src/services/DFGVariable.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ end
196196
"""
197197
$SIGNATURES
198198
199-
Get the PPE dictionary for a variable. Its direct use is not recomended.
199+
Get the PPE dictionary for a variable. Recommended to use CRUD operations instead, [`getPPE`](@ref), [`addPPE!`](@ref), [`updatePPE!`](@ref), [`deletePPE!`](@ref).
200200
"""
201201
getPPEDict(v::VariableDataLevel1) = v.ppeDict
202202

@@ -219,14 +219,25 @@ function getPPE(vari::VariableDataLevel1, solveKey::Symbol=:default)
219219
# return haskey(ppeDict, solveKey) ? ppeDict[solveKey] : nothing
220220
end
221221

222+
# afew more aliases on PPE, brought back from deprecated DF
223+
224+
"""
225+
$SIGNATURES
226+
227+
Return full dictionary of PPEs in a variable, recommended to rather use CRUD: [`getPPE`](@ref),
228+
"""
229+
getVariablePPEDict(vari::VariableDataLevel1) = getPPEDict(vari)
230+
231+
getVariablePPE(args...) = getPPE(args...)
232+
222233
##------------------------------------------------------------------------------
223234
## solverDataDict
224235
##------------------------------------------------------------------------------
225236

226237
"""
227238
$SIGNATURES
228239
229-
Get solver data dictionary for a variable.
240+
Get solver data dictionary for a variable. Advised to use graph CRUD operations instead.
230241
"""
231242
getSolverDataDict(v::DFGVariable) = v.solverDataDict
232243

@@ -542,7 +553,7 @@ deletePPE!(dfg::AbstractDFG, sourceVariable::DFGVariable, ppekey::Symbol=:defaul
542553
$(SIGNATURES)
543554
List all the PPE data keys in the variable.
544555
"""
545-
function listPPE(dfg::AbstractDFG, variablekey::Symbol)::Vector{Symbol}
556+
function listPPEs(dfg::AbstractDFG, variablekey::Symbol)::Vector{Symbol}
546557
v = getVariable(dfg, variablekey)
547558
return collect(keys(v.ppeDict))
548559
end

test/LightDFGSummaryTypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end
4040

4141
if VARTYPE == DFGVariableSummary
4242
@test getTimestamp(v1) == v1.timestamp
43-
@test getVariablePPEs(v1) == v1.ppeDict
43+
@test getVariablePPEDict(v1) == v1.ppeDict
4444
@test_throws KeyError getVariablePPE(v1, :notfound)
4545
@test getSofttypename(v1) == :Pose2
4646
@test getInternalId(v1) == v1._internalId

test/iifInterfaceTests.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ end
182182
@test getLabel(v1) == v1.label
183183
@test getTags(v1) == v1.tags
184184
@test getTimestamp(v1) == v1.timestamp
185-
@test getVariablePPEs(v1) == v1.ppeDict
185+
@test getVariablePPEDict(v1) == v1.ppeDict
186186
@test_throws Exception DistributedFactorGraphs.getVariablePPE(v1, :notfound)
187187
@test getSolverData(v1) === v1.solverDataDict[:default]
188188
@test getSolverData(v1) === v1.solverDataDict[:default]
189189
@test getSolverData(v1, :default) === v1.solverDataDict[:default]
190190
@test getSolverDataDict(v1) == v1.solverDataDict
191191
@test getInternalId(v1) == v1._internalId
192192
# legacy compat test
193-
@test getVariablePPEs(v1) == v1.ppeDict # changed to .ppeDict -- delete by DFG v0.7
193+
@test getVariablePPEDict(v1) == v1.ppeDict # changed to .ppeDict -- delete by DFG v0.7
194194

195195

196196
@test typeof(getSofttype(v1)) == ContinuousScalar
@@ -280,7 +280,7 @@ end
280280
var1 = getVariable(dfg, :a)
281281
#make a copy and simulate external changes
282282
newvar = deepcopy(var1)
283-
getVariablePPEs(newvar)[:default] = MeanMaxPPE(:default, [150.0], [100.0], [50.0])
283+
getVariablePPEDict(newvar)[:default] = MeanMaxPPE(:default, [150.0], [100.0], [50.0])
284284
#update
285285
# mergeUpdateVariableSolverData!(dfg, newvar)
286286
# mergeVariableSolverData!(getVariable(dfg,getLabel(newvar)), newvar)
@@ -289,29 +289,29 @@ end
289289

290290
#Check if variable is updated
291291
var1 = getVariable(dfg, :a)
292-
@test getVariablePPEs(newvar) == getVariablePPEs(var1)
292+
@test getVariablePPEDict(newvar) == getVariablePPEDict(var1)
293293

294294
# Add a new estimate.
295-
getVariablePPEs(newvar)[:second] = MeanMaxPPE(:second, [15.0], [10.0], [5.0])
295+
getVariablePPEDict(newvar)[:second] = MeanMaxPPE(:second, [15.0], [10.0], [5.0])
296296

297297
# Confirm they're different
298-
@test getVariablePPEs(newvar) != getVariablePPEs(var1)
298+
@test getVariablePPEDict(newvar) != getVariablePPEDict(var1)
299299
# Persist it.
300300
# mergeUpdateVariableSolverData!(dfg, newvar)
301301
# mergeVariableSolverData!(getVariable(dfg, getLabel(newvar)), newvar)
302302
mergeVariableData!(dfg, newvar)
303303
# Get the latest
304304
var1 = getVariable(dfg, :a)
305-
@test symdiff(collect(keys(getVariablePPEs(var1))), [:default, :second]) == Symbol[]
305+
@test symdiff(collect(keys(getVariablePPEDict(var1))), [:default, :second]) == Symbol[]
306306

307307
#Check if variable is updated
308-
@test getVariablePPEs(newvar) == getVariablePPEs(var1)
308+
@test getVariablePPEDict(newvar) == getVariablePPEDict(var1)
309309

310310

311311
# Delete :default and replace to see if new ones can be added
312-
delete!(getVariablePPEs(newvar), :default)
312+
delete!(getVariablePPEDict(newvar), :default)
313313
#confirm delete
314-
@test symdiff(collect(keys(getVariablePPEs(newvar))), [:second]) == Symbol[]
314+
@test symdiff(collect(keys(getVariablePPEDict(newvar))), [:second]) == Symbol[]
315315
# Persist it., and test
316316
mergeVariableData!(dfg, newvar)
317317
# mergeUpdateVariableSolverData!(dfg, newvar) #357 #358
@@ -320,8 +320,8 @@ end
320320
var1 = getVariable(dfg, :a)
321321

322322
# TODO issue #166
323-
@test getVariablePPEs(newvar) != getVariablePPEs(var1)
324-
@test collect(keys(getVariablePPEs(var1))) == [:default, :second]
323+
@test getVariablePPEDict(newvar) != getVariablePPEDict(var1)
324+
@test collect(keys(getVariablePPEDict(var1))) == [:default, :second]
325325

326326
# @test symdiff(collect(keys(getVariablePPE(getVariable(dfg, :a)))), [:default, :second]) == Symbol[]
327327
end

test/testBlocks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ function PPETestBlock!(fg, v1)
442442
@test_throws ErrorException addPPE!(fg, :a, ppe)
443443

444444

445-
@test listPPE(fg, :a) == [:default]
445+
@test listPPEs(fg, :a) == [:default]
446446
# Get the data back - note that this is a reference to above.
447447
@test getPPE(fg, :a, :default) == ppe
448448

@@ -468,7 +468,7 @@ function PPETestBlock!(fg, v1)
468468
# Add a new PPE of type MeanMaxPPE to :x0
469469
ppe = MeanMaxPPE(:default, [0.0], [0.0], [0.0])
470470
addPPE!(fg, :a, ppe)
471-
@test listPPE(fg, :a) == [:default]
471+
@test listPPEs(fg, :a) == [:default]
472472
# Get the data back - note that this is a reference to above.
473473
@test getPPE(fg, :a, :default) == ppe
474474

0 commit comments

Comments
 (0)