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

fix AbsRelRoots, InterpolationsExt #1744

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ TensorCast = "02d47bb6-7ce6-556a-be16-bb1710789e2b"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[weakdeps]
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"

[extensions]
InterpolationsExt = "Interpolations"

[compat]
ApproxManifoldProducts = "0.7"
BSON = "0.2, 0.3"
Expand Down Expand Up @@ -94,7 +100,6 @@ DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
Manopt = "0fc0a36d-df90-57f3-8f93-d78a9fc72bb5"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
10 changes: 0 additions & 10 deletions src/services/HeatmapSampler.jl → ext/HeatmapSampler.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# heatmap sampler (experimental)

@info "IncrementalInference.jl is loading tools related to Interpolations.jl."

using .Interpolations

# only export on Requires.jl
export HeatmapGridDensity, PackedHeatmapGridDensity
export LevelSetGridNormal, PackedLevelSetGridNormal

export sampleHeatmap

##

getManifold(hgd::HeatmapGridDensity) = getManifold(hgd.densityFnc)
Expand Down
25 changes: 25 additions & 0 deletions ext/InterpolationsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module InterpolationsExt

@info "IncrementalInference.jl is loading extensions related to Interpolations.jl."

using Interpolations
using Statistics
using DocStringExtensions
using TensorCast
using Manifolds
using ApproxManifoldProducts
import ApproxManifoldProducts: sample
const AMP = ApproxManifoldProducts

import IncrementalInference: getManifold
import IncrementalInference: HeatmapGridDensity, PackedHeatmapGridDensity
import IncrementalInference: LevelSetGridNormal, PackedLevelSetGridNormal

export HeatmapGridDensity, PackedHeatmapGridDensity
export LevelSetGridNormal, PackedLevelSetGridNormal
export sampleHeatmap


include("HeatmapSampler.jl")

end # module
1 change: 1 addition & 0 deletions ext/WeakDepsPrototypes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 3 additions & 3 deletions src/IncrementalInference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ function __init__()
@require DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" include(
"ODE/DERelative.jl",
)
@require Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" include(
"services/HeatmapSampler.jl",
)
# @require Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" include(
# "services/HeatmapSampler.jl",
# )

# combining neural networks natively into the non-Gaussian factor graph object
@require Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" begin
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include("testHeatmapGridDensity.jl")
include("testCliqSolveDbgUtils.jl")
include("basicGraphsOperations.jl")

include("TestModuleFunctions.jl")
# include("TestModuleFunctions.jl")
include("testCompareVariablesFactors.jl")
include("saveconvertertypes.jl")
include("testgraphpackingconverters.jl")
Expand Down Expand Up @@ -107,7 +107,7 @@ if Base.Sys.ARCH in [:x86_64;]
include("testTexTreeIllustration.jl")
end

include("testMultiprocess.jl")
# include("testMultiprocess.jl")
include("testDeadReckoningTether.jl")
end

Expand Down
2 changes: 1 addition & 1 deletion test/testCSMMonitor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using IncrementalInference
using Test

## a new factor that is broken
struct BrokenFactor{T<: SamplableBelief} <: AbstractRelativeRoots
struct BrokenFactor{T<: SamplableBelief} <: AbstractManifoldMinimize
Z::T
end

Expand Down
2 changes: 1 addition & 1 deletion test/testCalcFactorHypos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import IncrementalInference: getSample, getManifold

##

struct MyFactor{T <: SamplableBelief} <: IIF.AbstractRelativeRoots
struct MyFactor{T <: SamplableBelief} <: IIF.AbstractManifoldMinimize
Z::T
# specialSampler approach will be deprecated
# specialSampler::Function
Expand Down
2 changes: 1 addition & 1 deletion test/testCommonConvWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end

# abstract Nonparametric <: Function
# This is what the internmediate user would be contributing
mutable struct Pose1Pose1Test{T} <: AbstractRelativeRoots
mutable struct Pose1Pose1Test{T} <: AbstractManifoldMinimize
Dx::T
end

Expand Down
11 changes: 4 additions & 7 deletions test/testCompareVariablesFactors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ fg2 = deepcopy(fg)
@test compareSimilarVariables(fg, fg2)

@test compareSimilarFactors(fg, fg)
@test_broken compareSimilarFactors(fg, fg2; skip=[:particleidx])
@test compareSimilarFactors(fg, fg2; skip=[:particleidx])

@test compareFactorGraphs(fg, fg)
@test_broken compareFactorGraphs(fg, fg2; skip=[:particleidx; :varidx])
@test compareFactorGraphs(fg, fg2; skip=[:particleidx; :varidx])

# easier error messages
getSolverParams(fg).multiproc = false
Expand Down Expand Up @@ -78,13 +78,10 @@ Bl = IIF._getCCW(fg2, getLabel(f2))
field = :varValsAll
@test !compareField(Al, Bl, field)

@test_broken compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=true, skip=[:fullvariables; :varValsAll; :particleidx])
@test compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=true, skip=[:fullvariables; :varValsAll; :particleidx])

@test !compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=false)

@error "Suppressing one specific factor graph compare test post DFG v0.6.0 due to unknown (likely false) compare failure"
# @test compareFactorGraphs(fg, fg2, skipsamples=true, skipcompute=true, skip=[:initialized;:inferdim;:ppeDict; :solvedCount; :fncargvID])


##

Expand Down Expand Up @@ -113,7 +110,7 @@ sfg = buildSubgraph(fg, [:x0;:x1], 1) # distance=1 to include factors
#FIXME JT - this doesn't make sense to pass, it is a subgraph so should it not rather be ⊂ [subset]?
# compareDFG(fg1, fg2, by=⊂, skip=...)
@test fg.sessionLabel == sfg.sessionLabel[1:length(fg.sessionLabel)]
@test_broken compareFactorGraphs(fg, sfg, skip=[:labelDict;:addHistory;:logpath;:sessionLabel; :particleidx; :varidx])
@test compareFactorGraphs(fg, sfg, skip=[:labelDict;:addHistory;:logpath;:sessionLabel; :particleidx; :varidx])

# drawGraph(sfg)

Expand Down
2 changes: 1 addition & 1 deletion test/testDeadReckoningTether.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Test

##

mutable struct MutableLinearRelative{N, T <: SamplableBelief} <: AbstractRelativeRoots
mutable struct MutableLinearRelative{N, T <: SamplableBelief} <: AbstractManifoldMinimize
Z::T
# timestamp::DateTime
end
Expand Down
2 changes: 1 addition & 1 deletion test/testMixtureLinearConditional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ f1_ = DFG.unpackFactor(fg_, pf1)
@show typeof(getSolverData(f1).fnc.varValsAll[]);
@show typeof(getSolverData(f1_).fnc.varValsAll[]);

@test_broken DFG.compareFactor(f1, f1_, skip=[:components;:labels;:timezone;:zone;:vartypes;:fullvariables;:particleidx;:varidx])
@test DFG.compareFactor(f1, f1_, skip=[:components;:labels;:timezone;:zone;:vartypes;:fullvariables;:particleidx;:varidx])

@test IIF._getCCW(f1).usrfnc!.components.naive == IIF._getCCW(f1).usrfnc!.components.naive

Expand Down
2 changes: 1 addition & 1 deletion test/testSpecialSampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
getManifold(::SpecialPrior) = TranslationGroup(1)
getSample(s::CalcFactor{<:SpecialPrior}) = rand(s.factor.z,1)

struct SpecialLinearOffset{T <: SamplableBelief} <: AbstractRelativeRoots
struct SpecialLinearOffset{T <: SamplableBelief} <: AbstractManifoldMinimize
z::T
end
getManifold(::SpecialLinearOffset) = TranslationGroup(1)
Expand Down
2 changes: 1 addition & 1 deletion test/testmultihypothesisapi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end
getManifold(dp::DevelopPrior) = TranslationGroup(getDimension(dp.x))
getSample(cf::CalcFactor{<:DevelopPrior}) = rand(cf.factor.x, 1)

mutable struct DevelopLikelihood{T <: SamplableBelief} <: AbstractRelativeRoots
mutable struct DevelopLikelihood{T <: SamplableBelief} <: AbstractManifoldMinimize
x::T
end

Expand Down