Skip to content

Commit 2a042d1

Browse files
committed
Merge branch 'master' into maint/20Q2/test_maint
2 parents 2d08fcf + 3c8f3c1 commit 2a042d1

File tree

11 files changed

+90
-39
lines changed

11 files changed

+90
-39
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
- neo4j
1212

1313
julia:
14-
- 1.4
1514
- 1.5
1615
- nightly
1716

src/Deprecated.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ GraphsDFG{T}(args...; kwargs...) where T = GraphsDFG{T}()
2626

2727
@deprecate getInternalId(args...) error("getInternalId is no longer in use")
2828

29-
@deprecate loadDFG(source::String, iifModule::Module, dest::AbstractDFG) loadDFG!(dest, source)
29+
@deprecate loadDFG(source::AbstractString, iifModule::Module, dest::AbstractDFG) loadDFG!(dest, source)
30+
@deprecate loadDFG(dest::AbstractDFG, source::AbstractString) loadDFG!(dest, source)
3031

3132
# leave a bit longer
3233
export buildSubgraphFromLabels!

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export exists,
6868
updateVariable!, updateFactor!,
6969
deleteVariable!, deleteFactor!,
7070
listVariables, listFactors,
71+
listSolvekeys, listSupersolves,
7172
getVariables, getFactors,
7273
isVariable, isFactor
7374

src/FileDFG/services/FileDFG.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ v1 = addVariable!(dfg, :a, ContinuousScalar, labels = [:POSE], solvable=0)
1717
saveDFG(dfg, "/tmp/saveDFG.tar.gz")
1818
```
1919
"""
20-
function saveDFG( dfg::AbstractDFG, folder::String )
20+
function saveDFG( dfg::AbstractDFG, folder::AbstractString )
2121

2222
# TODO: Deprecate the folder functionality in v0.6.1
2323

@@ -82,7 +82,7 @@ loadDFG("/tmp/savedgraph.tar.gz", IncrementalInference, dfg)
8282
ls(dfg)
8383
```
8484
"""
85-
function loadDFG!(dfgLoadInto::AbstractDFG, dst::String)
85+
function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
8686

8787

8888
#
@@ -102,6 +102,8 @@ function loadDFG!(dfgLoadInto::AbstractDFG, dst::String)
102102
lastdirname *= ".tar.gz"
103103
end
104104
end
105+
# check the file actually exists
106+
@assert isfile(dstname) "cannot find file $dstname"
105107
# TODO -- what if it is not a tar.gz but classic folder instead?
106108
# do actual unzipping
107109
filename = lastdirname[1:(end-length(".tar.gz"))] |> string

src/entities/DFGFactor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mutable struct GenericFunctionNodeData{T<:Union{PackedInferenceType, FunctorInfe
3939
potentialused::Bool
4040
edgeIDs::Vector{Int}
4141
fnc::T
42-
multihypo::Vector{Float64} # likely to moved when GenericWrapParam is refactored
42+
multihypo::Vector{Float64} # FIXME likely to moved when GenericWrapParam is refactored #477
4343
certainhypo::Vector{Int}
4444
solveInProgress::Int
4545
end

src/services/AbstractDFG.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,24 @@ function listFactors(dfg::G, regexFilter::Union{Nothing, Regex}=nothing; tags::V
480480
return map(f -> f.label, getFactors(dfg, regexFilter, tags=tags, solvable=solvable))
481481
end
482482

483+
"""
484+
$SIGNATURES
485+
List all the solvekeys used amongst all variables in the distributed factor graph object.
486+
487+
Related
488+
489+
listSupersolves, getSolverDataDict, listVariables
490+
"""
491+
function listSolvekeys(dfg::AbstractDFG)
492+
skeys = Set{Symbol}()
493+
for vs in listVariables(dfg), ky in keys(getSolverDataDict(getVariable(dfg, vs)))
494+
push!(skeys, ky)
495+
end
496+
return skeys
497+
end
498+
const listSupersolves = listSolvekeys
499+
500+
483501
##------------------------------------------------------------------------------
484502
## Aliases and Other filtered lists
485503
##------------------------------------------------------------------------------

src/services/CustomPrinting.jl

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
##==============================================================================
2-
## Overloading show
3-
##==============================================================================
4-
# Base.show_default(io, v)
5-
Base.show(io::IO, ::MIME"text/plain", v::DFGVariable) = show(IOContext(io, :limit=>true, :compact=>true), v)
6-
7-
Base.show(io::IO, ::MIME"text/plain", f::DFGFactor) = show(IOContext(io, :limit=>true, :compact=>true), f)
8-
9-
function Base.show(io::IO, ::MIME"text/plain", dfg::AbstractDFG)
10-
summary(io, dfg)
11-
println("\n UserId: ", dfg.userId)
12-
println(" RobotId: ", dfg.robotId)
13-
println(" SessionId: ", dfg.sessionId)
14-
println(" Description: ", dfg.description)
15-
println(" Nr variables: ", length(ls(dfg)))
16-
println(" Nr factors: ",length(lsf(dfg)))
17-
println(" User Data: ", keys(dfg.userData))
18-
println(" Robot Data: ", keys(dfg.robotData))
19-
println(" Session Data: ", keys(dfg.sessionData))
20-
end
21-
22-
23-
#default for Atom/Juno
24-
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::Union{AbstractDFG, DFGVariable, DFGFactor}) = x
25-
26-
271
##==============================================================================
282
## Printing Variables and Factors
293
##==============================================================================
@@ -83,11 +57,23 @@ function printFactor(io::IO, vert::DFGFactor;
8357

8458
if short
8559
printstyled(ioc, summary(vert),"\n", bold=true)
86-
println(ioc, "label: ", vert.label)
87-
println(ioc, "timestamp: ", vert.timestamp)
88-
println(ioc, "tags: ", vert.tags)
89-
println(ioc, "solvable: ", vert.solvable)
90-
println(ioc, "VariableOrder: ", vert._variableOrderSymbols)
60+
println(ioc, " label: ", vert.label)
61+
println(ioc, " solvable: ", vert.solvable)
62+
println(ioc, " VariableOrder: ", vert._variableOrderSymbols)
63+
println(ioc, " multihypo: ", getSolverData(vert).multihypo) # FIXME #477
64+
println(ioc, " nullhypo: ", "see DFG #477")
65+
println(ioc, " timestamp: ", vert.timestamp)
66+
println(ioc, " nstime: ",vert.nstime)
67+
println(ioc, " tags: ", vert.tags)
68+
fct = getFactorType(vert)
69+
fctt = fct |> typeof
70+
println(ioc, " Type: ", fctt)
71+
# show(ioc, fctt)
72+
for f in setdiff(fieldnames(fctt), skipfields)
73+
printstyled(ioc, f,":\n", color=:blue)
74+
show(ioc, getproperty(fct, f))
75+
println(ioc)
76+
end
9177
else
9278

9379
printstyled(ioc, summary(vert),"\n", bold=true, color=:blue)
@@ -125,3 +111,29 @@ Dev Notes
125111
printVariable(dfg::AbstractDFG, sym::Symbol; kwargs...) = printVariable(getVariable(dfg, sym); kwargs...)
126112

127113
printNode(dfg::AbstractDFG, sym::Symbol; kwargs...) = isVariable(dfg,sym) ? printVariable(dfg, sym; kwargs...) : printFactor(dfg, sym; kwargs...)
114+
115+
116+
##==============================================================================
117+
## Overloading show
118+
##==============================================================================
119+
# Base.show_default(io, v)
120+
Base.show(io::IO, ::MIME"text/plain", v::DFGVariable) = show(IOContext(io, :limit=>true, :compact=>true), v)
121+
122+
Base.show(io::IO, ::MIME"text/plain", f::DFGFactor) = printFactor(io, f, short=true, limit=false)
123+
124+
function Base.show(io::IO, ::MIME"text/plain", dfg::AbstractDFG)
125+
summary(io, dfg)
126+
println(io, "\n UserId: ", dfg.userId)
127+
println(io, " RobotId: ", dfg.robotId)
128+
println(io, " SessionId: ", dfg.sessionId)
129+
println(io, " Description: ", dfg.description)
130+
println(io, " Nr variables: ", length(ls(dfg)))
131+
println(io, " Nr factors: ",length(lsf(dfg)))
132+
println(io, " User Data: ", keys(dfg.userData))
133+
println(io, " Robot Data: ", keys(dfg.robotData))
134+
println(io, " Session Data: ", keys(dfg.sessionData))
135+
end
136+
137+
138+
#default for Atom/Juno
139+
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::Union{AbstractDFG, DFGVariable, DFGFactor}) = x

test/fileDFGTests.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ using Test
4545
saveDFG(dfg, filename)
4646

4747
copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
48+
copyDf2 = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
4849
@info "Going to load $filename"
4950

50-
#FIXME loadDFG!(copyDfg, filename), but use this to test deprecation
51-
retDFG = loadDFG(filename, Main, copyDfg) #, loaddir="/tmp")
51+
@test_throws AssertionError loadDFG!(copyDf2,"badfilename")
52+
53+
retDFG = loadDFG!(copyDfg, filename)
54+
# TODO REMOVE test deprecation
55+
retDFG_ = loadDFG(filename, Main, copyDf2) #, loaddir="/tmp")
5256

5357
@test issetequal(ls(dfg), ls(retDFG))
5458
@test issetequal(lsf(dfg), lsf(retDFG))

test/iifInterfaceTests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ end
1313
v1 = addVariable!(dfg, :a, ContinuousScalar, labels = [:POSE], solvable=0)
1414
v2 = addVariable!(dfg, :b, ContinuousScalar, labels = [:LANDMARK], solvable=1)
1515
f1 = addFactor!(dfg, [:a; :b], LinearConditional(Normal(50.0,2.0)), solvable=0)
16+
17+
@show dfg
18+
@show f1
19+
@show v1
1620
end
1721

1822
#test before anything changes

test/interfaceTests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ end
6262
String(take!(iobuf)) == "DFGFactor{TestCCW{TestFunctorInferenceType1}}\nlabel:\n:abf1\ntags:\nSet([:tag1, :tag2])\nsolvable:\n0\nsolvable:\n1\n_variableOrderSymbols:\n[:a, :b]\n"
6363

6464
@test printFactor(iobuf, fac1, short=true) == nothing
65-
@test occursin(r"DFGFactor.*\nlabel.*\ntimestamp.*\ntags.*\nsolvable", String(take!(iobuf)))
65+
@show teststr = String(take!(iobuf))
66+
@test occursin(r"DFGFactor", teststr)
67+
@test occursin(r"label", teststr)
68+
@test occursin(r"timestamp", teststr)
69+
@test occursin(r"tags", teststr)
70+
@test occursin(r"solvable", teststr)
6671

6772
# s = String(take!(iobuf))
6873

test/testBlocks.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ end
506506
@test ls(fg) == listVariables(fg)
507507
@test lsf(fg) == listFactors(fg)
508508

509+
if getVariable(fg, ls(fg)[1]) isa DFGVariable
510+
@test :default in listSolvekeys(fg)
511+
@test :default in listSupersolves(fg)
512+
end
513+
509514
# simple broadcast test
510515
if f0 isa DFGFactor
511516
@test issetequal(getFactorType.(fg, lsf(fg)), [TestFunctorInferenceType1(), TestFunctorSingleton()])

0 commit comments

Comments
 (0)