From c0cc383f01a688fb1b77c1135aa5f86df3ce8110 Mon Sep 17 00:00:00 2001 From: dehann Date: Tue, 11 Jul 2023 01:51:31 -0700 Subject: [PATCH] isapprox for hyporecipe --- src/entities/HypoRecipe.jl | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/entities/HypoRecipe.jl b/src/entities/HypoRecipe.jl index 9b2ca4f5..b6d08eb8 100644 --- a/src/entities/HypoRecipe.jl +++ b/src/entities/HypoRecipe.jl @@ -18,4 +18,33 @@ Base.@kwdef struct HypoRecipeCompute{ certainhypo::CH = nothing """ subsection indices to select which params should be used for this hypothesis evaluation """ activehypo::Vector{Int} = Int[] -end \ No newline at end of file +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)