@@ -114,34 +114,38 @@ Related
114
114
ls, lsf
115
115
"""
116
116
sortDFG (vars:: Vector{Symbol} ):: Vector{Symbol} = sortVarNested (vars)
117
- """
118
- $SIGNATURES
119
-
120
- Return the factor type used in a `::DFGFactor`.
121
-
122
- Notes:
123
- - OBSOLETE, use newer getFactorType instead.
124
-
125
- Related
126
117
127
- getFactorType
128
- """
129
- function getfnctype (data:: GenericFunctionNodeData )
130
- # TODO what is this?
131
- if typeof (data). name. name == :VariableNodeData
132
- return VariableNodeData
133
- end
134
-
135
- # this looks right
136
- return data. fnc. usrfnc!
137
- end
138
- function getfnctype (fact:: DFGFactor ; solveKey:: Symbol = :default )
139
- data = getSolverData (fact) # TODO , solveKey=solveKey)
140
- return getfnctype (data)
141
- end
142
- function getfnctype (dfg:: T , lbl:: Symbol ; solveKey:: Symbol = :default ) where T <: AbstractDFG
143
- getfnctype (getFactor (dfg, exvertid))
144
- end
118
+ # TODO Is this deprecate in favor of getFactorType, or OBSOLETE?
119
+ # """
120
+ # $SIGNATURES
121
+ #
122
+ # Return the factor type used in a `::DFGFactor`.
123
+ #
124
+ # Notes:
125
+ # - OBSOLETE, use newer getFactorType instead.
126
+ #
127
+ # Related
128
+ #
129
+ # getFactorType
130
+ # """
131
+ # function getfnctype(data::GenericFunctionNodeData)
132
+ # # TODO what is this?
133
+ # if typeof(data).name.name == :VariableNodeData
134
+ # return VariableNodeData
135
+ # end
136
+ #
137
+ # # this looks right
138
+ # return data.fnc.usrfnc!
139
+ # end
140
+ # function getfnctype(fact::DFGFactor; solveKey::Symbol=:default)
141
+ # data = getSolverData(fact) # TODO , solveKey=solveKey)
142
+ # return getfnctype(data)
143
+ # end
144
+ # function getfnctype(dfg::T, lbl::Symbol; solveKey::Symbol=:default) where T <: AbstractDFG
145
+ # getfnctype(getFactor(dfg, exvertid))
146
+ # end
147
+
148
+ @deprecate getfnctype (args... ) getFactorType (args... )
145
149
146
150
"""
147
151
$SIGNATURES
190
194
191
195
Return the DFGVariable softtype in factor graph `dfg<:AbstractDFG` and label `::Symbol`.
192
196
"""
193
- getVariableType (var:: DFGVariable ; solveKey :: Symbol = :default ) = getSofttype (var, solveKey = solveKey )
194
- function getVariableType (dfg:: G , lbl:: Symbol ; solveKey :: Symbol = :default ) where G <: AbstractDFG
195
- getVariableType (getVariable (dfg, lbl), solveKey = solveKey )
197
+ getVariableType (var:: DFGVariable ) = getSofttype (var)
198
+ function getVariableType (dfg:: G , lbl:: Symbol ) where G <: AbstractDFG
199
+ getVariableType (getVariable (dfg, lbl))
196
200
end
197
201
198
202
@@ -241,9 +245,9 @@ function lsTypes(dfg::G)::Dict{Symbol, Vector{String}} where G <: AbstractDFG
241
245
end
242
246
243
247
244
- function ls (dfg:: G , :: Type{T} ; solveKey :: Symbol = :default ) where {G <: AbstractDFG , T <: InferenceVariable }
248
+ function ls (dfg:: G , :: Type{T} ) where {G <: AbstractDFG , T <: InferenceVariable }
245
249
xx = getVariables (dfg)
246
- mask = getVariableType .(xx, solveKey = solveKey ) .| > typeof .== T
250
+ mask = getVariableType .(xx) .| > typeof .== T
247
251
vxx = view (xx, mask)
248
252
map (x-> x. label, vxx)
249
253
end
@@ -274,11 +278,11 @@ Related
274
278
275
279
ls, lsf, lsfPriors
276
280
"""
277
- function lsWho (dfg:: AbstractDFG , type:: Symbol ; solveKey :: Symbol = :default ):: Vector{Symbol}
281
+ function lsWho (dfg:: AbstractDFG , type:: Symbol ):: Vector{Symbol}
278
282
vars = getVariables (dfg)
279
283
labels = Symbol[]
280
284
for v in vars
281
- varType = typeof (getVariableType (v, solveKey = solveKey )). name |> Symbol
285
+ varType = typeof (getVariableType (v)). name |> Symbol
282
286
varType == type && push! (labels, v. label)
283
287
end
284
288
return labels
@@ -390,48 +394,56 @@ function findVariableNearTimestamp(dfg::AbstractDFG,
390
394
return RET
391
395
end
392
396
397
+
398
+ # TAGS as a set, list, merge, remove, empty
393
399
"""
394
400
$SIGNATURES
395
401
396
402
Return the tags for a variable or factor.
397
403
"""
398
- function getTags (dfg:: InMemoryDFGTypes , sym:: Symbol )
404
+ function listTags (dfg:: InMemoryDFGTypes , sym:: Symbol )
399
405
getFnc = isVariable (dfg,sym) ? getVariable : getFactor
400
406
getTags (getFnc (dfg, sym))
401
407
end
408
+ # alias for completeness
409
+ listTags (f:: DataLevel0 ) = getTags (f)
402
410
403
411
"""
404
412
$SIGNATURES
405
413
406
- Add tags to a variable or factor
414
+ Merge add tags to a variable or factor (union)
407
415
"""
408
- function addTags ! (dfg:: InMemoryDFGTypes , sym:: Symbol , tags:: Vector{Symbol} )
416
+ function mergeTags ! (dfg:: InMemoryDFGTypes , sym:: Symbol , tags:: Vector{Symbol} )
409
417
getFnc = isVariable (dfg,sym) ? getVariable : getFactor
410
418
union! (getTags (getFnc (dfg, sym)), tags)
411
419
end
420
+ mergeTags! (f:: DataLevel0 , tags:: Vector{Symbol} ) = union! (f. tags, tags)
412
421
413
422
414
423
"""
415
424
$SIGNATURES
416
425
417
- Add tag to a variable or factor
426
+ Remove the tags from the node (setdiff)
418
427
"""
419
- addTag! (f:: DataLevel0 , tag:: Symbol ) = union! (f. tags,[tag])
420
-
428
+ function removeTags! (dfg:: InMemoryDFGTypes , sym:: Symbol , tags:: Vector{Symbol} )
429
+ getFnc = isVariable (dfg,sym) ? getVariable : getFactor
430
+ setdiff! (getTags (getFnc (dfg, sym)), tags)
431
+ end
432
+ removeTags! (f:: DataLevel0 , tags:: Vector{Symbol} ) = setdiff! (f. tags, tags)
421
433
422
434
"""
423
435
$SIGNATURES
424
436
425
- Merge tags to the node's tags (variable/factor).
437
+ Empty all tags from the node (empty)
426
438
"""
427
- mergeTags! (f:: DataLevel0 , tags:: Vector{Symbol} ) = union! (f. tags, tags)
439
+ function emptyTags! (dfg:: InMemoryDFGTypes , sym:: Symbol )
440
+ getFnc = isVariable (dfg,sym) ? getVariable : getFactor
441
+ empty! (getTags (getFnc (dfg, sym)))
442
+ end
443
+ emptyTags! (f:: DataLevel0 ) = empty! (f. tags)
444
+
428
445
429
- """
430
- $SIGNATURES
431
446
432
- Remove the tags from the node
433
- """
434
- deleteTags! (f:: DataLevel0 , tags:: Vector{Symbol} ) = setdiff! (f. tags, tags)
435
447
436
448
437
449
"""
@@ -444,7 +456,7 @@ function hasTags(dfg::InMemoryDFGTypes,
444
456
tags:: Vector{Symbol} ;
445
457
matchAll:: Bool = true ):: Bool
446
458
#
447
- alltags = getTags (dfg, sym)
459
+ alltags = listTags (dfg, sym)
448
460
length (filter (x-> x in alltags, tags)) >= (matchAll ? length (tags) : 1 )
449
461
end
450
462
0 commit comments