Skip to content

Commit

Permalink
Merge pull request #823 from JuliaRobotics/21Q4/enh/listdes
Browse files Browse the repository at this point in the history
new feature listDataEntrySequence
  • Loading branch information
dehann authored Nov 22, 2021
2 parents 9d7e873 + 639aff5 commit e651723
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DistributedFactorGraphs"
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
version = "0.17.0"
version = "0.17.1"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
32 changes: 31 additions & 1 deletion src/DataBlobs/services/AbstractDataEntries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ end

"""
$(SIGNATURES)
listDataEntries
List the data entries associated with a particular variable.
"""
function listDataEntries(var::AbstractDFGVariable)
collect(keys(var.dataDict))
Expand All @@ -135,3 +135,33 @@ function listDataEntries(dfg::AbstractDFG, label::Symbol)
# !isVariable(dfg, label) && return nothing
listDataEntries(getVariable(dfg, label))
end

"""
$SIGNATURES
List a collection of data entries per variable that match a particular `pattern::Regex`.
Notes
- Optional sort function argument, default is unsorted.
- Likely use of `sortDFG` for basic Symbol sorting.
Example
```julia
listDataEntrySequence(fg, :x0, r"IMG_CENTER", sortDFG)
15-element Vector{Symbol}:
:IMG_CENTER_21676
:IMG_CENTER_21677
:IMG_CENTER_21678
:IMG_CENTER_21679
...
```
"""
function listDataEntrySequence( dfg::AbstractDFG,
lb::Symbol,
pattern::Regex,
_sort::Function=(x)->x)
#
ents_ = listDataEntries(dfg, lb)
entReg = map(l->match(pattern, string(l)), ents_)
entMsk = entReg .!== nothing
ents_[findall(entMsk)] |> _sort
end
6 changes: 3 additions & 3 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ const fetchData = getDataEntryBlob
## softtype deprections
function Base.getproperty(x::InferenceVariable, f::Symbol)
if f==:dims
Base.depwarn("Softtype $(typeof(x)), field dims is deprecated, extend and use `getDimension` instead",:getproperty)
Base.depwarn("varType $(typeof(x)), field dims is deprecated, extend and use `getDimension` instead",:getproperty)
elseif f==:manifolds
Base.depwarn("Softtype $(typeof(x)), field manifolds is deprecated, extend and use `getManifolds` instead",:getproperty)
Base.depwarn("varType $(typeof(x)), field manifolds is deprecated, extend and use `getManifold` instead",:getproperty)
else
if !(@isdefined softtypeFieldsWarnOnce)
Base.depwarn("Softtype $(typeof(x)), will be required to be a singleton type in the future and can no longer have fields. *.$f called. Further warnings are suppressed",:getproperty)
Base.depwarn("varType $(typeof(x)), will be required to be a singleton type in the future and can no longer have fields. *.$f called. Further warnings are suppressed",:getproperty)
global softtypeFieldsWarnOnce = true
end
end
Expand Down
1 change: 1 addition & 0 deletions src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph!
# Big Data
##------------------------------------------------------------------------------
export addDataEntry!, getDataEntry, updateDataEntry!, deleteDataEntry!, getDataEntries, listDataEntries, hasDataEntry, hasDataEntry
export listDataEntrySequence
# convenience wrappers
export addDataEntry!
# aliases
Expand Down
2 changes: 1 addition & 1 deletion src/LightDFG/services/LightDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ Example
using IncrementalInference
# canonical example graph as example
fg = generateCanonicalFG_Kaess()
fg = generateGraph_Kaess()
@show path = findShortestPathDijkstra(fg, :x1, :x3)
@show isVariable.(fg, path)
Expand Down

0 comments on commit e651723

Please sign in to comment.