Skip to content

Commit b645cdd

Browse files
committed
improve testing
1 parent 0444f4f commit b645cdd

11 files changed

Lines changed: 139 additions & 78 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ SHA = "0.7, 1"
6464
SparseArrays = "1.11"
6565
StaticArrays = "1"
6666
Statistics = "1.11"
67-
Tables = "v1.11.1"
67+
Tables = "1.11.1"
6868
Tar = "1.9"
6969
TensorCast = "0.3.3, 0.4"
7070
Test = "1.11"

src/DistributedFactorGraphs.jl

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,32 +263,44 @@ export getId
263263
##------------------------------------------------------------------------------
264264
## Types
265265
##------------------------------------------------------------------------------
266-
export InMemoryDFGTypes
267-
export LocalDFG
268-
export FolderStore
266+
public InMemoryDFGTypes
267+
public LocalDFG
268+
public FolderStore
269269

270270
##------------------------------------------------------------------------------
271271
## Tags
272272
##------------------------------------------------------------------------------
273273
# tags is a set: get/list, merge, empty, and remove (we don't have add but merge)
274-
export getTags
275-
export listTags
276-
export mergeTags!
277-
export emptyTags!
278-
export removeTags! #TODO do we want this one
274+
275+
export listVariableTags
276+
export listFactorTags
277+
export listGraphTags
278+
export listAgentTags
279+
280+
export mergeVariableTags!
281+
export mergeFactorTags!
282+
export mergeGraphTags!
283+
export mergeAgentTags!
284+
285+
public listTags
286+
public mergeTags!
287+
public emptyTags!
288+
public deleteTags! #TODO do we want this one
279289

280290
##------------------------------------------------------------------------------
281291
## Bloblets
282292
##------------------------------------------------------------------------------
283293
# currently these refer to variable Bloblets
284294
#TODO Bloblet CRUD
285-
# export getVariableBloblet
286-
# export addVariableBloblet!
287-
# export deleteVariableBloblet!
288-
# export listVariableBloblets
295+
export Bloblet
296+
export getVariableBloblet
297+
export addVariableBloblet!
298+
export mergeVariableBloblet!
299+
export deleteVariableBloblet!
300+
export listVariableBloblets
289301

290-
# export getAgentBloblet
291-
# export getGraphBloblet
302+
export getAgentBloblet
303+
export getGraphBloblet
292304

293305
##------------------------------------------------------------------------------
294306
## FileDFG
@@ -331,10 +343,12 @@ export @format_str # exported from FileIO
331343

332344
export @defStateType #TODO Should this be exported?
333345

346+
public refStates
347+
334348
# list of unstable functions not exported any more
335349
# will move to public or deprecate over time
336350
const unstable_functions::Vector{Symbol} = [
337-
:refStates, #internal maybe make public
351+
:getTags,
338352
:InMemoryBlobstore,
339353
:getFactorState, # FIXME getFactorState were questioned and being reviewed again for name, other than that they are checked.
340354
:exists,

src/GraphsDFG/GraphsDFG.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ using ...DistributedFactorGraphs:
2222
getGraphLabel,
2323
isInitialized,
2424
Bloblets,
25-
Blobentries
25+
Blobentries,
26+
FolderStore,
27+
refTags,
28+
listTags
2629

2730
# import DFG functions to extend
2831
import ...DistributedFactorGraphs:

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function getVariables(
173173
"tags kwarg is deprecated, use kwarg `tagsFilter = !isdisjoint(tags)` instead", #v0.28
174174
:getVariables,
175175
)
176-
filterDFG!(variables, x -> !isdisjoint(x, tags), getTags)
176+
filterDFG!(variables, x -> !isdisjoint(x, tags), refTags)
177177
end
178178
if !isnothing(solvable)
179179
#TODO review. just one solvableFilter or keep solvable as well.
@@ -186,7 +186,7 @@ function getVariables(
186186

187187
filterDFG!(variables, labelFilter, getLabel)
188188
filterDFG!(variables, solvableFilter, getSolvable)
189-
filterDFG!(variables, tagsFilter, getTags)
189+
filterDFG!(variables, tagsFilter, refTags)
190190
filterDFG!(variables, typeFilter, getVariableType)
191191

192192
return variables
@@ -254,7 +254,7 @@ function getFactors(
254254
"tags kwarg is deprecated, use kwarg `tagsFilter = !isdisjoint(tags)` instead", #v0.28
255255
:getFactors,
256256
)
257-
filterDFG!(factors, x -> !isdisjoint(x, tags), getTags)
257+
filterDFG!(factors, x -> !isdisjoint(x, tags), refTags)
258258
end
259259
if !isnothing(solvable)
260260
#TODO review. just one solvableFilter or keep solvable as well.
@@ -267,7 +267,7 @@ function getFactors(
267267

268268
filterDFG!(factors, labelFilter, getLabel)
269269
filterDFG!(factors, solvableFilter, getSolvable)
270-
filterDFG!(factors, tagsFilter, getTags)
270+
filterDFG!(factors, tagsFilter, refTags)
271271
filterDFG!(factors, typeFilter, typeof getObservation)
272272
return factors
273273
end
@@ -357,7 +357,7 @@ function listNeighbors(
357357
# Additional filtering
358358
# solvable != 0 && filter!(lbl -> _isSolvable(dfg, lbl, solvable), neighbors_ll)
359359
filterDFG!(neighbors_ll, solvableFilter, l->getSolvable(dfg, l))
360-
filterDFG!(neighbors_ll, tagsFilter, l->getTags(dfg, l))
360+
filterDFG!(neighbors_ll, tagsFilter, l->listTags(dfg, l))
361361

362362
# Variable sorting (order is important)
363363
if haskey(dfg.g.factors, label)

src/entities/Bloblet.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ struct Bloblet
33
val::String
44
end
55

6+
function Bloblet(
7+
label::Symbol,
8+
val::Union{
9+
Int,
10+
Float64,
11+
Bool,
12+
Vector{Int},
13+
Vector{Float64},
14+
Vector{String},
15+
Vector{Bool},
16+
Missing,
17+
Nothing,
18+
},
19+
)
20+
return Bloblet(label, JSON.json(val))
21+
end
22+
623
const Bloblets = LittleDict{Symbol, Bloblet}
724

825
StructUtils.structlike(::Type{Bloblets}) = false

src/entities/DFGFactor.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ StructUtils.@kwarg struct FactorDFG{T <: AbstractObservation, N} <: AbstractGrap
6060
Accessor: [`getLabel`](@ref)"""
6161
label::Symbol
6262
"""Factor tags, e.g [:FACTOR].
63-
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
63+
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
6464
tags::Set{Symbol} = Set{Symbol}([:FACTOR])
6565
"""Ordered list of the neighbor variables.
6666
Accessors: [`getVariableOrder`](@ref)"""
@@ -218,7 +218,7 @@ Base.@kwdef struct FactorSummary <: AbstractGraphFactor
218218
Accessor: [`getLabel`](@ref)"""
219219
label::Symbol
220220
"""Factor tags, e.g [:FACTOR].
221-
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
221+
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
222222
tags::Set{Symbol}
223223
"""Ordered list of the neighbor variables.
224224
Accessors: [`getVariableOrder`](@ref)"""
@@ -254,7 +254,7 @@ Base.@kwdef struct FactorSkeleton <: AbstractGraphFactor
254254
Accessor: [`getLabel`](@ref)"""
255255
label::Symbol
256256
"""Factor tags, e.g [:FACTOR].
257-
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
257+
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
258258
tags::Set{Symbol}
259259
"""Ordered list of the neighbor variables.
260260
Accessors: [`getVariableOrder`](@ref)"""

src/entities/DFGVariable.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ $(TYPEDFIELDS)
152152
steadytime::Union{Nothing, Nanosecond} = nothing #NOTE changed to TimeDateZone in v0.29
153153
#nstime::String = "0" #NOTE different uses, as 0-999_999 nanosecond part of timestamp now in timestamp, as steady timestamp now in steadytime
154154
"""Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
155-
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
155+
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
156156
tags::Set{Symbol} = Set{Symbol}()
157157
"""Dictionary of state data. May be a subset of all solutions if a solver label was specified in the get call.
158158
Accessors: [`addState!`](@ref), [`mergeState!`](@ref), and [`deleteState!`](@ref)"""
@@ -297,7 +297,7 @@ $(TYPEDFIELDS)
297297
Accessors: [`getTimestamp`](@ref)"""
298298
timestamp::TimeDateZone
299299
"""Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
300-
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
300+
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
301301
tags::Set{Symbol}
302302
"""Symbol for the state type for the underlying variable.
303303
Accessor: [`getStateType`](@ref)"""
@@ -324,7 +324,7 @@ Base.@kwdef struct VariableSkeleton <: AbstractGraphVariable
324324
Accessor: [`getLabel`](@ref)"""
325325
label::Symbol
326326
"""Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
327-
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
327+
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`deleteTags!`](@ref)"""
328328
tags::Set{Symbol} = Set{Symbol}()
329329
end
330330

src/services/CustomPrinting.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function printVariable(
4141
printstyled(ioc, vert.label; bold = true)
4242
println(ioc)
4343
println(ioc, " solvable: ", getSolvable(vert))
44-
println(ioc, " tags: ", getTags(vert))
44+
println(ioc, " tags: ", listTags(vert))
4545
solk = listStates(vert)
4646
lsolk = length(solk)
4747
smsk = lsolk > 0 ? (rand(1:lsolk, 100) |> unique)[1:minimum([4, lsolk])] : nothing

src/services/Tags.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,33 @@ end
1616
## TAGS as a set, list, merge, remove, empty
1717
##==============================================================================
1818

19-
listTags(node) = node.tags
19+
listTags(node) = collect(refTags(node))
20+
2021
"""
2122
$SIGNATURES
2223
2324
Merge add tags to a variable or factor (union)
2425
"""
25-
mergeTags!(node, tags::Vector{Symbol}) = union!(node.tags, tags)
26+
function mergeTags!(node, tags)
27+
union!(refTags(node), tags)
28+
return length(tags)
29+
end
2630
"""
2731
$SIGNATURES
2832
2933
Remove the tags from the node (setdiff)
3034
"""
31-
removeTags!(node, tags::Vector{Symbol}) = setdiff!(node.tags, tags)
35+
function deleteTags!(node, tags)
36+
setdiff!(refTags(node), tags)
37+
return length(tags)
38+
end
39+
3240
"""
3341
$SIGNATURES
3442
3543
Empty all tags from the node (empty)
3644
"""
37-
emptyTags!(node) = empty!(node.tags)
45+
emptyTags!(node) = empty!(refTags(node))
3846

3947
"""
4048
$SIGNATURES
@@ -43,7 +51,7 @@ Return the tags for a variable or factor.
4351
"""
4452

4553
#alias for completeness #TODO keep or remove getTags?
46-
const getTags = listTags
54+
const getTags = refTags
4755

4856
function listVariableTags(dfg::AbstractDFG, sym::Symbol)
4957
return listTags(getVariable(dfg, sym))
@@ -105,7 +113,7 @@ function mergeTags!(dfg::InMemoryDFGTypes, sym::Symbol, tags)
105113
return union!(refTags(getFnc(dfg, sym)), tags)
106114
end
107115

108-
function removeTags!(dfg::InMemoryDFGTypes, sym::Symbol, tags)
116+
function deleteTags!(dfg::InMemoryDFGTypes, sym::Symbol, tags)
109117
getFnc = isVariable(dfg, sym) ? getVariable : getFactor
110118
return setdiff!(refTags(getFnc(dfg, sym)), tags)
111119
end

test/interfaceTests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ end
116116
end
117117

118118
#FIXME replace with Bloblets tests
119-
# @testset "Metadata CRUD" begin
120-
# smallDataTestBlock!(fg1)
121-
# end
119+
@testset "Bloblet CRUD" begin
120+
blobletTestBlock!(fg1)
121+
end
122122

123123
@testset "Data Entries and Blobs" begin
124124
if typeof(fg1) <: InMemoryDFGTypes

0 commit comments

Comments
 (0)