Skip to content

Commit e2b1e17

Browse files
authored
Merge pull request #349 from JuliaRobotics/fix/1Q20/320
better printing api,
2 parents 6c545c1 + d2fefff commit e2b1e17

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ export
228228
## needsahome.jl
229229

230230
export buildSubgraphFromLabels!
231-
export printFactor, printVariable
231+
232+
import Base: print
233+
export printFactor, printVariable, print
232234

233235
##==============================================================================
234236
## Files Includes

src/needsahome.jl

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Into, Labels, Subgraph are all implied from the parameters.
44
# can alies names but like Sam suggested only on copy is needed.
55

6+
67
"""
78
$SIGNATURES
89
Construct a new factor graph object as a subgraph of `dfg <: AbstractDFG` based on the
@@ -62,24 +63,8 @@ function buildSubgraphFromLabels!(dfg::G,
6263
return subfg
6364
end
6465

65-
"""
66-
$SIGNATURES
6766

68-
Display and return to console the user factor identified by tag name.
69-
"""
70-
printFactor(fgl::AbstractDFG, fsym::Symbol) = @show getFactor(fgl,fsym)
71-
72-
73-
"""
74-
$SIGNATURES
75-
76-
Display the content of `VariableNodeData` to console for a given factor graph and variable tag`::Symbol`.
77-
78-
Dev Notes
79-
- TODO split as two show macros between AMP and DFG
80-
"""
81-
function printVariable(fgl::AbstractDFG, vsym::Symbol, solveKey::Symbol=:default)
82-
vert = getVariable(fgl, vsym)
67+
function print(vert::DFGVariable, solveKey::Symbol=:default)
8368
vnd = getSolverData(vert, solveKey)
8469
println("label: $(vert.label)")
8570
println("tags: $(getTags(vert))")
@@ -96,6 +81,29 @@ function printVariable(fgl::AbstractDFG, vsym::Symbol, solveKey::Symbol=:default
9681
vnd
9782
end
9883

84+
print(fct::DFGFactor) = @show fct
85+
86+
87+
"""
88+
$SIGNATURES
89+
90+
Display and return to console the user factor identified by tag name.
91+
"""
92+
printFactor(fgl::AbstractDFG, fsym::Symbol) = print(getFactor(dfg, sym))
93+
94+
"""
95+
$SIGNATURES
96+
97+
Display the content of `VariableNodeData` to console for a given factor graph and variable tag`::Symbol`.
98+
99+
Dev Notes
100+
- TODO split as two show macros between AMP and DFG
101+
"""
102+
printVariable(fgl::AbstractDFG, vsym::Symbol, solveKey::Symbol=:default) = print(getVariable(dfg, sym))
103+
104+
print(fgl::AbstractDFG, fsym::Symbol) = isVariable(dfg,fsym) ? printVariable(dfg, fsym) : printFactor(dfg, sym)
105+
106+
99107
## KEEPING COMMENT, WANT TO BE CONSOLIDATED WITH FUNCTION ABOVE -- KEEPING ONLY ONE FOR MAINTAINABILITY
100108
## STILL NEEDS TO BE CONSOLIDATED WITH `DFG._copyIntoGraph`
101109
# """

0 commit comments

Comments
 (0)