Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove all return types and deprecate lsfWho #1092

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $(SIGNATURES)

Returns true if the label is valid for a session, robot, or user ID.
"""
function isValidLabel(id::Union{Symbol, String})::Bool
function isValidLabel(id::Union{Symbol, String})
if typeof(id) == Symbol
id = String(id)
end
Expand Down
2 changes: 1 addition & 1 deletion src/GraphsDFG/FactorGraphs/FactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function addFactor!(
g::FactorGraph{T, V, F},
variableLabels::Vector{Symbol},
factor::F,
)::Bool where {T, V, F}
) where {T, V, F}
haskey(g.labels, factor.label) &&
(@error "Label $(factor.label) already in fg"; return false)

Expand Down
19 changes: 8 additions & 11 deletions src/GraphsDFG/services/GraphsDFG.jl
Affie marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end
function addVariable!(
dfg::GraphsDFG{<:AbstractParams, V, <:AbstractDFGFactor},
variable::V,
)::V where {V <: AbstractDFGVariable}
) where {V <: AbstractDFGVariable}
#TODO should this be an error
if haskey(dfg.g.variables, variable.label)
error("Variable '$(variable.label)' already exists in the factor graph")
Expand All @@ -58,7 +58,7 @@ end
function addVariable!(
dfg::GraphsDFG{<:AbstractParams, VD, <:AbstractDFGFactor},
variable::AbstractDFGVariable,
)::VD where {VD <: AbstractDFGVariable}
) where {VD <: AbstractDFGVariable}
return addVariable!(dfg, VD(variable))
end

Expand Down Expand Up @@ -186,7 +186,7 @@ function deleteFactor!(
dfg::GraphsDFG,
label::Symbol;
suppressGetFactor::Bool = false,
)::AbstractDFGFactor
)
if !haskey(dfg.g.factors, label)
error("Factor label '$(label)' does not exist in the factor graph")
end
Expand Down Expand Up @@ -285,12 +285,12 @@ function listFactors(
return factors::Vector{Symbol}
end

function isConnected(dfg::GraphsDFG)::Bool
function isConnected(dfg::GraphsDFG)
return Graphs.is_connected(dfg.g)
# return length(Graphs.connected_components(dfg.g)) == 1
end

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

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

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

Expand Down Expand Up @@ -375,10 +375,7 @@ function getBiadjacencyMatrix(
solvable::Int = 0,
varLabels = listVariables(dfg; solvable = solvable),
factLabels = listFactors(dfg; solvable = solvable),
)::NamedTuple{
(:B, :varLabels, :facLabels),
Tuple{Graphs.SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}},
}
)
varIndex = [dfg.g.labels[s] for s in varLabels]
factIndex = [dfg.g.labels[s] for s in factLabels]

Expand Down
4 changes: 2 additions & 2 deletions src/services/AbstractDFG.jl
Affie marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ function listFactors(
regexFilter::Union{Nothing, Regex} = nothing;
tags::Vector{Symbol} = Symbol[],
solvable::Int = 0,
)::Vector{Symbol} where {G <: AbstractDFG}
) where {G <: AbstractDFG}
return map(f -> f.label, getFactors(dfg, regexFilter; tags = tags, solvable = solvable))
end

Expand Down Expand Up @@ -754,7 +754,7 @@ function lsf(
dfg::G,
label::Symbol;
solvable::Int = 0,
)::Vector{Symbol} where {G <: AbstractDFG}
) where {G <: AbstractDFG}
return listNeighbors(dfg, label; solvable = solvable)
end

Expand Down
10 changes: 5 additions & 5 deletions src/services/CommonAccessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ Variables or factors may or may not be 'solvable', depending on a user definitio
Related:
- isSolveInProgress
"""
getSolvable(var::Union{DFGVariable, DFGFactor})::Int = var.solvable
getSolvable(var::Union{DFGVariable, DFGFactor}) = var.solvable
#TODO DataLevel2

"""
$SIGNATURES

Get 'solvable' parameter for either a variable or factor.
"""
function getSolvable(dfg::AbstractDFG, sym::Symbol)::Int
function getSolvable(dfg::AbstractDFG, sym::Symbol)
if isVariable(dfg, sym)
return getVariable(dfg, sym).solvable
elseif isFactor(dfg, sym)
Expand All @@ -110,7 +110,7 @@ end

Set the `solvable` parameter for either a variable or factor.
"""
function setSolvable!(node::N, solvable::Int)::Int where {N <: DFGNode}
function setSolvable!(node::N, solvable::Int) where {N <: DFGNode}
node.solvable = solvable
return solvable
end
Expand All @@ -120,7 +120,7 @@ end

Set the `solvable` parameter for either a variable or factor.
"""
function setSolvable!(dfg::AbstractDFG, sym::Symbol, solvable::Int)::Int
function setSolvable!(dfg::AbstractDFG, sym::Symbol, solvable::Int)
if isVariable(dfg, sym)
getVariable(dfg, sym).solvable = solvable
elseif isFactor(dfg, sym)
Expand Down Expand Up @@ -158,7 +158,7 @@ isSolvable
function getSolveInProgress(
var::Union{DFGVariable, DFGFactor},
solveKey::Symbol = :default,
)::Int
)
Comment on lines 158 to +161
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function getSolveInProgress(
var::Union{DFGVariable, DFGFactor},
solveKey::Symbol = :default,
)::Int
)
function getSolveInProgress(var::Union{DFGVariable, DFGFactor}, solveKey::Symbol = :default)

# Variable
if var isa DFGVariable
if haskey(getSolverDataDict(var), solveKey)
Expand Down
4 changes: 2 additions & 2 deletions src/services/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ Retrieve the soft type name symbol for a DFGVariableSummary. ie :Point2, Pose2,
"""
getVariableTypeName(v::DFGVariableSummary) = v.variableTypeName::Symbol

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