Skip to content

Commit c0cc383

Browse files
committed
isapprox for hyporecipe
1 parent ea131ca commit c0cc383

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/entities/HypoRecipe.jl

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,33 @@ Base.@kwdef struct HypoRecipeCompute{
1818
certainhypo::CH = nothing
1919
""" subsection indices to select which params should be used for this hypothesis evaluation """
2020
activehypo::Vector{Int} = Int[]
21-
end
21+
end
22+
23+
24+
function Base.isapprox(
25+
a::HypoRecipe,
26+
b::HypoRecipe
27+
)
28+
if !(isnothing(a.hypotheses) && isnothing(B.hypotheses))
29+
return isapprox(a.hypotheses.p, b.hypotheses.p)
30+
end
31+
if !(isnothing(a.certainhypo) && isnothing(B.certainhypo))
32+
return isapprox(a.certainhypo, b.certainhypo)
33+
end
34+
35+
if 0 < length(a.activehypo)
36+
if length(a.activehypo) == length(b.activehypo)
37+
return isapprox(a.activehypo, b.activehypo)
38+
else
39+
return false
40+
end
41+
end
42+
43+
return true
44+
end
45+
46+
47+
Base.==(
48+
a::HypoRecipe,
49+
b::HypoRecipe
50+
) = isapprox(a,b)

0 commit comments

Comments
 (0)