Skip to content

Commit 817eb84

Browse files
authored
Merge pull request #1092 from JuliaRobotics/24Q3/maintanance
remove all return types and deprecate lsfWho
2 parents afff497 + e98bc54 commit 817eb84

10 files changed

+31
-51
lines changed

src/Common.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ $(SIGNATURES)
9191
9292
Returns true if the label is valid for a session, robot, or user ID.
9393
"""
94-
function isValidLabel(id::Union{Symbol, String})::Bool
94+
function isValidLabel(id::Union{Symbol, String})
9595
if typeof(id) == Symbol
9696
id = String(id)
9797
end

src/Deprecated.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
##=================================================================================
55
@deprecate getBlobEntry(var::AbstractDFGVariable, key::AbstractString) getBlobEntryFirst(var, Regex(key))
66

7+
@deprecate lsfWho(dfg::AbstractDFG, type::Symbol) lsf(dfg, getfield(Main, type))
8+
79
## ================================================================================
810
## Deprecated in v0.23
911
##=================================================================================

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export isValidLabel
286286
## List
287287
export ls, lsf, ls2
288288
export lsTypes, lsfTypes, lsTypesDict, lsfTypesDict
289-
export lsWho, lsfWho
289+
export lsWho
290290
export isPrior, lsfPriors
291291
export hasTags, hasTagsNeighbors
292292

src/GraphsDFG/FactorGraphs/FactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function addFactor!(
134134
g::FactorGraph{T, V, F},
135135
variableLabels::Vector{Symbol},
136136
factor::F,
137-
)::Bool where {T, V, F}
137+
) where {T, V, F}
138138
haskey(g.labels, factor.label) &&
139139
(@error "Label $(factor.label) already in fg"; return false)
140140

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ end
4141
function addVariable!(
4242
dfg::GraphsDFG{<:AbstractParams, V, <:AbstractDFGFactor},
4343
variable::V,
44-
)::V where {V <: AbstractDFGVariable}
44+
) where {V <: AbstractDFGVariable}
4545
#TODO should this be an error
4646
if haskey(dfg.g.variables, variable.label)
4747
error("Variable '$(variable.label)' already exists in the factor graph")
@@ -58,7 +58,7 @@ end
5858
function addVariable!(
5959
dfg::GraphsDFG{<:AbstractParams, VD, <:AbstractDFGFactor},
6060
variable::AbstractDFGVariable,
61-
)::VD where {VD <: AbstractDFGVariable}
61+
) where {VD <: AbstractDFGVariable}
6262
return addVariable!(dfg, VD(variable))
6363
end
6464

@@ -186,7 +186,7 @@ function deleteFactor!(
186186
dfg::GraphsDFG,
187187
label::Symbol;
188188
suppressGetFactor::Bool = false,
189-
)::AbstractDFGFactor
189+
)
190190
if !haskey(dfg.g.factors, label)
191191
error("Factor label '$(label)' does not exist in the factor graph")
192192
end
@@ -285,12 +285,12 @@ function listFactors(
285285
return factors::Vector{Symbol}
286286
end
287287

288-
function isConnected(dfg::GraphsDFG)::Bool
288+
function isConnected(dfg::GraphsDFG)
289289
return Graphs.is_connected(dfg.g)
290290
# return length(Graphs.connected_components(dfg.g)) == 1
291291
end
292292

293-
function _isSolvable(dfg::GraphsDFG, label::Symbol, ready::Int)::Bool
293+
function _isSolvable(dfg::GraphsDFG, label::Symbol, ready::Int)
294294
haskey(dfg.g.variables, label) && (return dfg.g.variables[label].solvable >= ready)
295295
haskey(dfg.g.factors, label) && (return dfg.g.factors[label].solvable >= ready)
296296

@@ -321,7 +321,7 @@ function listNeighbors(dfg::GraphsDFG, node::DFGNode; solvable::Int = 0)
321321
return neighbors_ll::Vector{Symbol}
322322
end
323323

324-
function listNeighbors(dfg::GraphsDFG, label::Symbol; solvable::Int = 0)::Vector{Symbol}
324+
function listNeighbors(dfg::GraphsDFG, label::Symbol; solvable::Int = 0)
325325
if !exists(dfg, label)
326326
error("Variable/factor with label '$(label)' does not exist in the factor graph")
327327
end
@@ -345,7 +345,7 @@ function getNeighborhood(
345345
variableFactorLabels::Vector{Symbol},
346346
distance::Int;
347347
solvable::Int = 0,
348-
)::Vector{Symbol}
348+
)
349349
# find neighbors at distance to add
350350
nbhood = Int[]
351351

@@ -375,10 +375,7 @@ function getBiadjacencyMatrix(
375375
solvable::Int = 0,
376376
varLabels = listVariables(dfg; solvable = solvable),
377377
factLabels = listFactors(dfg; solvable = solvable),
378-
)::NamedTuple{
379-
(:B, :varLabels, :facLabels),
380-
Tuple{Graphs.SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}},
381-
}
378+
)
382379
varIndex = [dfg.g.labels[s] for s in varLabels]
383380
factIndex = [dfg.g.labels[s] for s in factLabels]
384381

src/services/AbstractDFG.jl

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ function listFactors(
637637
regexFilter::Union{Nothing, Regex} = nothing;
638638
tags::Vector{Symbol} = Symbol[],
639639
solvable::Int = 0,
640-
)::Vector{Symbol} where {G <: AbstractDFG}
640+
) where {G <: AbstractDFG}
641641
return map(f -> f.label, getFactors(dfg, regexFilter; tags = tags, solvable = solvable))
642642
end
643643

@@ -754,7 +754,7 @@ function lsf(
754754
dfg::G,
755755
label::Symbol;
756756
solvable::Int = 0,
757-
)::Vector{Symbol} where {G <: AbstractDFG}
757+
) where {G <: AbstractDFG}
758758
return listNeighbors(dfg, label; solvable = solvable)
759759
end
760760

@@ -775,6 +775,15 @@ function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactor}
775775
return map(x -> x.label, vxx)
776776
end
777777

778+
"""
779+
$(SIGNATURES)
780+
Lists the factors of a specific type in the factor graph.
781+
Example, list all the Point2Point2 factors in the factor graph `dfg`:
782+
lsfWho(dfg, :Point2Point2)
783+
784+
Notes
785+
- Return `Vector{Symbol}`
786+
"""
778787
function lsf(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactor}
779788
return ls(dfg, T)
780789
end
@@ -837,32 +846,6 @@ function lsWho(dfg::AbstractDFG, type::Symbol)
837846
return labels
838847
end
839848

840-
"""
841-
$(SIGNATURES)
842-
Gives back all factor labels that fit the bill:
843-
lsfWho(dfg, :Point2Point2)
844-
845-
Notes
846-
- Returns `Vector{Symbol}`
847-
848-
Dev Notes
849-
- Cloud versions will benefit from less data transfer
850-
- `ls(dfg::C, ::T) where {C <: CloudDFG, T <: ..}`
851-
852-
Related
853-
854-
ls, lsf, lsfPriors
855-
"""
856-
function lsfWho(dfg::AbstractDFG, type::Symbol)
857-
facs = getFactors(dfg)
858-
labels = Symbol[]
859-
for f in facs
860-
facType = typeof(getFactorType(f)) |> nameof
861-
facType == type && push!(labels, f.label)
862-
end
863-
return labels
864-
end
865-
866849
## list types
867850
##-----------
868851

src/services/CommonAccessors.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ Variables or factors may or may not be 'solvable', depending on a user definitio
8888
Related:
8989
- isSolveInProgress
9090
"""
91-
getSolvable(var::Union{DFGVariable, DFGFactor})::Int = var.solvable
91+
getSolvable(var::Union{DFGVariable, DFGFactor}) = var.solvable
9292
#TODO DataLevel2
9393

9494
"""
9595
$SIGNATURES
9696
9797
Get 'solvable' parameter for either a variable or factor.
9898
"""
99-
function getSolvable(dfg::AbstractDFG, sym::Symbol)::Int
99+
function getSolvable(dfg::AbstractDFG, sym::Symbol)
100100
if isVariable(dfg, sym)
101101
return getVariable(dfg, sym).solvable
102102
elseif isFactor(dfg, sym)
@@ -110,7 +110,7 @@ end
110110
111111
Set the `solvable` parameter for either a variable or factor.
112112
"""
113-
function setSolvable!(node::N, solvable::Int)::Int where {N <: DFGNode}
113+
function setSolvable!(node::N, solvable::Int) where {N <: DFGNode}
114114
node.solvable = solvable
115115
return solvable
116116
end
@@ -120,7 +120,7 @@ end
120120
121121
Set the `solvable` parameter for either a variable or factor.
122122
"""
123-
function setSolvable!(dfg::AbstractDFG, sym::Symbol, solvable::Int)::Int
123+
function setSolvable!(dfg::AbstractDFG, sym::Symbol, solvable::Int)
124124
if isVariable(dfg, sym)
125125
getVariable(dfg, sym).solvable = solvable
126126
elseif isFactor(dfg, sym)
@@ -158,7 +158,7 @@ isSolvable
158158
function getSolveInProgress(
159159
var::Union{DFGVariable, DFGFactor},
160160
solveKey::Symbol = :default,
161-
)::Int
161+
)
162162
# Variable
163163
if var isa DFGVariable
164164
if haskey(getSolverDataDict(var), solveKey)

src/services/DFGVariable.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ Retrieve the soft type name symbol for a DFGVariableSummary. ie :Point2, Pose2,
643643
"""
644644
getVariableTypeName(v::DFGVariableSummary) = v.variableTypeName::Symbol
645645

646-
function getVariableType(v::DFGVariableSummary)::InferenceVariable
646+
function getVariableType(v::DFGVariableSummary)
647647
@warn "Looking for type in `Main`. Only use if `variableType` has only one implementation, ie. Pose2. Otherwise use the full variable."
648648
return getfield(Main, v.variableTypeName)()
649649
end
@@ -921,7 +921,7 @@ end
921921
$(SIGNATURES)
922922
List all the solver data keys in the variable.
923923
"""
924-
function listVariableSolverData(dfg::AbstractDFG, variablekey::Symbol)::Vector{Symbol}
924+
function listVariableSolverData(dfg::AbstractDFG, variablekey::Symbol)
925925
v = getVariable(dfg, variablekey)
926926
return collect(keys(v.solverDataDict))
927927
end

test/iifInterfaceTests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ end
157157

158158
@test ls(dfg, LinearRelative) == [:abf1]
159159
@test lsf(dfg, LinearRelative) == [:abf1]
160-
@test lsfWho(dfg, :LinearRelative) == [:abf1]
161160

162161
@test getVariableType(v1) isa Position{1}
163162
@test getVariableType(dfg, :a) isa Position{1}

test/testBlocks.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,6 @@ function testGroup!(fg, v1, v2, f0, f1)
12071207

12081208
@test ls(fg, TestFunctorInferenceType1) == [:abf1]
12091209
@test lsf(fg, TestAbstractPrior) == [:af1]
1210-
@test lsfWho(fg, :TestFunctorInferenceType1) == [:abf1]
12111210

12121211
@test getVariableType(v1) == TestVariableType1()
12131212
@test getVariableType(fg, :a) == TestVariableType1()

0 commit comments

Comments
 (0)