Skip to content

Commit fa7503e

Browse files
committed
add lsfPriors
1 parent ed0fd4c commit fa7503e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Common.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,30 @@ function sortVarNested(vars::Vector{Symbol})::Vector{Symbol}
7575
end
7676
return retvars
7777
end
78+
79+
80+
"""
81+
$SIGNATURES
82+
83+
Return `::Bool` on whether given factor `fc::Symbol` is a prior in factor graph `dfg`.
84+
"""
85+
function isPrior(dfg::G, fc::Symbol)::Bool where G <: AbstractDFG
86+
fco = getFactor(dfg, fc)
87+
getfnctype(fco) isa FunctorSingleton
88+
end
89+
90+
"""
91+
$SIGNATURES
92+
93+
Return vector of prior factor symbol labels in factor graph `dfg`.
94+
"""
95+
function lsfPriors(dfg::G)::Vector{Symbol} where G <: AbstractDFG
96+
priors = Symbol[]
97+
fcts = lsf(dfg)
98+
for fc in fcts
99+
if isPrior(dfg, fc)
100+
push!(priors, fc)
101+
end
102+
end
103+
return priors
104+
end

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export GenericFunctionNodeData#, FunctionNodeData
3131
export getSerializationModule, setSerializationModule!
3232
export pack, unpack
3333

34+
export isPrior, lsfPriors
35+
3436
include("services/AbstractDFG.jl")
3537
include("services/DFGVariable.jl")
3638

0 commit comments

Comments
 (0)