Skip to content

Commit

Permalink
Merge pull request #537 from JuliaRobotics/enhancement/533_functorrename
Browse files Browse the repository at this point in the history
Update as per #533
  • Loading branch information
dehann authored Jul 19, 2020
2 parents cdcc0dd + 8302241 commit 8dc2597
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
4 changes: 4 additions & 0 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function buildSubgraphFromLabels!(dfg::AbstractDFG,

end

# These will become AbstractPrior, AbstractRelativeFactor, and AbstractRelativeFactorMinimize in 0.9.
abstract type FunctorSingleton <: FunctorInferenceType end
abstract type FunctorPairwise <: FunctorInferenceType end
abstract type FunctorPairwiseMinimize <: FunctorInferenceType end

##==============================================================================
## Remove in 0.10
Expand Down
4 changes: 2 additions & 2 deletions src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ export addData!, fetchData, fetchDataEntryBlob
# Factor Data
export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData
export InferenceType, PackedInferenceType, FunctorInferenceType, FactorOperationalMemory
export AbstractPrior, AbstractRelativeFactor, AbstractRelativeFactorMinimize
#Deprecated
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize

# accessors
Expand Down Expand Up @@ -236,8 +238,6 @@ export


## Deprecated exports should be listed in Deprecated.jl if possible, otherwise here
#TODO remove export in DFG v0.8.0
# export ConvolutionObject

## CustomPrinting.jl
export printFactor, printVariable, printNode
Expand Down
6 changes: 3 additions & 3 deletions src/entities/DFGFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ abstract type FactorOperationalMemory <: Function end
# we can add to IIF or have IIF.CommonConvWrapper <: FactorOperationalMemory directly
# abstract type ConvolutionObject <: FactorOperationalMemory end

abstract type FunctorSingleton <: FunctorInferenceType end
abstract type FunctorPairwise <: FunctorInferenceType end
abstract type FunctorPairwiseMinimize <: FunctorInferenceType end
abstract type AbstractPrior <: FunctorInferenceType end
abstract type AbstractRelativeFactor <: FunctorInferenceType end
abstract type AbstractRelativeFactorMinimize <: FunctorInferenceType end

##==============================================================================
## GenericFunctionNodeData
Expand Down
2 changes: 1 addition & 1 deletion src/services/DFGFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Return `::Bool` on whether given factor `fc::Symbol` is a prior in factor graph
"""
function isPrior(dfg::G, fc::Symbol)::Bool where G <: AbstractDFG
fco = getFactor(dfg, fc)
getFactorType(fco) isa FunctorSingleton
getFactorType(fco) isa AbstractPrior || getFactorType(fco) isa FunctorSingleton
end


Expand Down
34 changes: 17 additions & 17 deletions test/testBlocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ end
struct TestFunctorInferenceType1 <: FunctorInferenceType end
struct TestFunctorInferenceType2 <: FunctorInferenceType end

struct TestFunctorSingleton <: FunctorSingleton end
struct TestFunctorPairwise <: FunctorPairwise end
struct TestFunctorPairwiseMinimize <: FunctorPairwiseMinimize end
struct TestAbstractPrior <: AbstractPrior end
struct TestAbstractRelativeFactor <: AbstractRelativeFactor end
struct TestAbstractRelativeFactorMinimize <: AbstractRelativeFactorMinimize end

struct PackedTestFunctorInferenceType1 <: PackedInferenceType
s::String
Expand All @@ -41,19 +41,19 @@ function Base.convert(::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInf
TestFunctorInferenceType1()
end

struct PackedTestFunctorSingleton <: PackedInferenceType
struct PackedTestAbstractPrior <: PackedInferenceType
s::String
end
PackedTestFunctorSingleton() = PackedTestFunctorSingleton("")
PackedTestAbstractPrior() = PackedTestAbstractPrior("")

function Base.convert(::Type{PackedTestFunctorSingleton}, d::TestFunctorSingleton)
# @info "convert(::Type{PackedTestFunctorSingleton}, d::TestFunctorSingleton)"
PackedTestFunctorSingleton()
function Base.convert(::Type{PackedTestAbstractPrior}, d::TestAbstractPrior)
# @info "convert(::Type{PackedTestAbstractPrior}, d::TestAbstractPrior)"
PackedTestAbstractPrior()
end

function Base.convert(::Type{TestFunctorSingleton}, d::PackedTestFunctorSingleton)
# @info "onvert(::Type{TestFunctorSingleton}, d::PackedTestFunctorSingleton)"
TestFunctorSingleton()
function Base.convert(::Type{TestAbstractPrior}, d::PackedTestAbstractPrior)
# @info "onvert(::Type{TestAbstractPrior}, d::PackedTestAbstractPrior)"
TestAbstractPrior()
end

struct TestCCW{T} <: FactorOperationalMemory where {T<:FunctorInferenceType}
Expand Down Expand Up @@ -315,7 +315,7 @@ function DFGFactorSCA()
f1_tags = Set([:FACTOR])
testTimestamp = now()

gfnd_prior = GenericFunctionNodeData(false, false, Int[], TestCCW(TestFunctorSingleton()))
gfnd_prior = GenericFunctionNodeData(false, false, Int[], TestCCW(TestAbstractPrior()))

gfnd = GenericFunctionNodeData(false, false, Int[], TestCCW(TestFunctorInferenceType1()))

Expand Down Expand Up @@ -513,7 +513,7 @@ end

# simple broadcast test
if f0 isa DFGFactor
@test issetequal(getFactorType.(fg, lsf(fg)), [TestFunctorInferenceType1(), TestFunctorSingleton()])
@test issetequal(getFactorType.(fg, lsf(fg)), [TestFunctorInferenceType1(), TestAbstractPrior()])
end
@test getVariable.(fg, [:a]) == [getVariable(fg, :a)]
end
Expand Down Expand Up @@ -836,15 +836,15 @@ function testGroup!(fg, v1, v2, f0, f1)
@test isPrior(fg, :af1) # if f1 is prior
@test lsfPriors(fg) == [:af1]

@test issetequal([:TestFunctorInferenceType1, :TestFunctorSingleton], lsfTypes(fg))
@test issetequal([:TestFunctorInferenceType1, :TestAbstractPrior], lsfTypes(fg))

facTypesDict = lsfTypesDict(fg)
@test issetequal(collect(keys(facTypesDict)), lsfTypes(fg))
@test issetequal(facTypesDict[:TestFunctorInferenceType1], [:abf1])
@test issetequal(facTypesDict[:TestFunctorSingleton], [:af1])
@test issetequal(facTypesDict[:TestAbstractPrior], [:af1])

@test ls(fg, TestFunctorInferenceType1) == [:abf1]
@test lsf(fg, TestFunctorSingleton) == [:af1]
@test lsf(fg, TestAbstractPrior) == [:af1]
@test lsfWho(fg, :TestFunctorInferenceType1) == [:abf1]

@test getSofttype(v1) == TestSofttype1()
Expand Down Expand Up @@ -899,7 +899,7 @@ function testGroup!(fg, v1, v2, f0, f1)
@test issetequal(ls(fg, tags=[:POSE, :LANDMARK]), ls(fg, tags=[:VARIABLE]))

@test lsf(fg, tags=[:NONE]) == []
@test lsf(fg, tags=[:PRIOR]) == [:af1]
@test lsf(fg, tags=[:PRIOR]) == [:af1]

# Regexes
@test ls(fg, r"a") == [v1.label]
Expand Down

0 comments on commit 8dc2597

Please sign in to comment.