-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1743 from JuliaRobotics/master
ff == HypoRecipeCompute
- Loading branch information
Showing
3 changed files
with
71 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |