Skip to content

Commit 3d33f71

Browse files
committed
fix and cleanup defVariable
1 parent 3200541 commit 3d33f71

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/services/DFGVariable.jl

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ getVariableType(dfg::AbstractDFG, lbl::Symbol) = getVariableType(getVariable(dfg
6363
##------------------------------------------------------------------------------
6464
## InferenceVariable
6565
##------------------------------------------------------------------------------
66-
"""
67-
$SIGNATURES
68-
Interface function to return the `variableType` dimension of an InferenceVariable, extend this function for all Types<:InferenceVariable.
69-
"""
70-
function getDimension end
71-
"""
72-
$SIGNATURES
73-
Interface function to return the `<:ManifoldsBase.AbstractManifold` object of `variableType<:InferenceVariable`, extend this function for all `Types<:InferenceVariable`.
74-
"""
75-
getManifold(vari::DFGVariable) = getVariableType(vari) |> getManifold
7666

7767
# """
7868
# $SIGNATURES
@@ -83,7 +73,6 @@ getManifold(vari::DFGVariable) = getVariableType(vari) |> getManifold
8373
# getManifolds(::Type{<:T}) where {T <: ManifoldsBase.AbstractManifold} = convert(Tuple, T)
8474
# getManifolds(::T) where {T <: ManifoldsBase.AbstractManifold} = getManifolds(T)
8575

86-
getDimension(t_::T) where {T <: ManifoldsBase.AbstractManifold} = manifold_dimension(t_)
8776

8877
"""
8978
@defVariable StructName manifolds<:ManifoldsBase.AbstractManifold
@@ -101,23 +90,36 @@ macro defVariable(structname, manifold)
10190
return esc(quote
10291
Base.@__doc__ struct $structname <: InferenceVariable end
10392

104-
@assert ($manifold isa AbstractManifold) "@defVariable of "*string($structname)*" requires that the "*string($manifold)*" be a subtype of `ManifoldsBase.AbstractManifold`"
105-
10693
# user manifold must be a <:Manifold
107-
Base.convert(::Type{<:AbstractManifold}, ::Union{<:T, Type{<:T}}) where {T <: $structname} = $manifold
94+
@assert ($manifold isa AbstractManifold) "@defVariable of "*string($structname)*" requires that the "*string($manifold)*" be a subtype of `ManifoldsBase.AbstractManifold`"
10895

109-
getManifold(::Type{M}) where {M <: $structname} = $manifold
110-
getManifold(::M) where {M <: $structname} = getManifold(M)
111-
112-
DFG.getDimension(::Type{M}) where {M <: $structname} = manifold_dimension(getManifold(M))
113-
DFG.getDimension(::M) where {M <: $structname} = manifold_dimension(getManifold(M))
96+
DFG.getManifold(::Type{$structname}) = $manifold
11497

115-
# # # FIXME legacy API to be deprecated
116-
# DFG.getManifolds(::Type{M}) where {M <: $structname} = convert(Tuple, $manifold)
117-
# DFG.getManifolds(::M) where {M <: $structname} = convert(Tuple, $manifold)
11898
end)
11999
end
120100

101+
Base.convert(::Type{<:AbstractManifold}, ::Union{<:T, Type{<:T}}) where {T <: InferenceVariable} = getManifold(T)
102+
103+
"""
104+
$SIGNATURES
105+
Interface function to return the `<:ManifoldsBase.AbstractManifold` object of `variableType<:InferenceVariable`.
106+
"""
107+
getManifold(vari::DFGVariable) = getVariableType(vari) |> getManifold
108+
getManifold(::T) where {T <: InferenceVariable} = getManifold(T)
109+
110+
111+
"""
112+
$SIGNATURES
113+
Interface function to return the `variableType` dimension of an InferenceVariable, extend this function for all Types<:InferenceVariable.
114+
"""
115+
function getDimension end
116+
117+
getDimension(::Type{T}) where {T <: InferenceVariable} = manifold_dimension(getManifold(T))
118+
getDimension(::T) where {T <: InferenceVariable} = manifold_dimension(getManifold(T))
119+
getDimension(M::ManifoldsBase.AbstractManifold) = manifold_dimension(M)
120+
121+
122+
121123
##------------------------------------------------------------------------------
122124
## solvedCount
123125
##------------------------------------------------------------------------------

0 commit comments

Comments
 (0)