Skip to content

Commit

Permalink
Merge pull request #1743 from JuliaRobotics/master
Browse files Browse the repository at this point in the history
ff == HypoRecipeCompute
  • Loading branch information
dehann authored Jul 11, 2023
2 parents 6246654 + 1f1c2f4 commit fa0b40f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/IncrementalInference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ include("entities/AliasScalarSampling.jl")
include("entities/OptionalDensities.jl")
include("entities/BeliefTypes.jl")

include("services/HypoRecipe.jl")

#
include("manifolds/services/ManifoldsExtentions.jl")
include("manifolds/services/ManifoldSampling.jl")
Expand Down
28 changes: 0 additions & 28 deletions src/entities/HypoRecipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,3 @@ Base.@kwdef struct HypoRecipeCompute{
activehypo::Vector{Int} = Int[]
end


function Base.isapprox(
a::HypoRecipe,
b::HypoRecipe
)
if !(isnothing(a.hypotheses) && isnothing(b.hypotheses))
return isapprox(a.hypotheses.p, b.hypotheses.p)
end
if !(isnothing(a.certainhypo) && isnothing(b.certainhypo))
return isapprox(a.certainhypo, b.certainhypo)
end

if 0 < length(a.activehypo)
if length(a.activehypo) == length(b.activehypo)
return isapprox(a.activehypo, b.activehypo)
else
return false
end
end

return true
end


Base.:(==)(
a::HypoRecipe,
b::HypoRecipe
) = isapprox(a,b)
69 changes: 69 additions & 0 deletions src/services/HypoRecipe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

function Base.isapprox(
a::HypoRecipe,
b::HypoRecipe;
iakws...
)
if !(
isapprox(a.certainidx, b.certainidx; iakws...) &&
isapprox(a.mhidx, b.mhidx; iakws...)
)
@debug "HypoRecipe a vs b not the same on either .certainidx or .mhidx"
return false
end
if length(a.allelements) != length(b.allelements)
@debug "HypoRecipe different lengths on a vs b .allelements"
return false
end
for (i,el) in enumerate(a.allelements)
if !isapprox(el, b.allelements[i]; iakws...)
@debug "HypoRecipe a vs b different on .allelements"
return false
end
end
if length(a.allelements) != length(b.allelements)
@debug "HypoRecipe different lengths on a vs b .activehypo"
return false
end
for (i,el) in enumerate(a.activehypo)
if el[1] != b.activehypo[i][1] || !isapprox(el[2], b.activehypo[i][2]; iakws...)
@debug "HypoRecipe a vs b different on .activehypo"
return false
end
end
return true
end

Base.:(==)(
a::HypoRecipe,
b::HypoRecipe
) = isapprox(a,b)

function Base.isapprox(
a::HypoRecipeCompute,
b::HypoRecipeCompute;
iakws...
)
if !(isnothing(a.hypotheses) && isnothing(b.hypotheses))
return isapprox(a.hypotheses.p, b.hypotheses.p; iakws...)
end
if !(isnothing(a.certainhypo) && isnothing(b.certainhypo))
return isapprox(a.certainhypo, b.certainhypo; iakws...)
end

if 0 < length(a.activehypo)
if length(a.activehypo) == length(b.activehypo)
return isapprox(a.activehypo, b.activehypo; iakws...)
else
return false
end
end

return true
end


Base.:(==)(
a::HypoRecipeCompute,
b::HypoRecipeCompute
) = isapprox(a,b)

0 comments on commit fa0b40f

Please sign in to comment.