#49 Add better errors for get_natural_manifold_base and ...#51
Conversation
…nt for Binomial, Categorical, NegativeBinomial, Weibull
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #51 +/- ##
==========================================
- Coverage 89.20% 87.32% -1.88%
==========================================
Files 21 21
Lines 250 292 +42
==========================================
+ Hits 223 255 +32
- Misses 27 37 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I don't think that this is actually what issue is about to be honest. And these checks however could be usefull I do not see immidiatly why we need to add it, because we have these checks on the side of Could you motivate your changes? |
|
This is not a bad change and also doesn't hurt performance, but I would use Julia dispatch instead, for example this function get_natural_manifold_base(::Type{Categorical}, ::Tuple{}, conditioner=nothing)
if conditioner === nothing
throw(
ArgumentError(
"get_natural_manifold_base(::Type{Categorical},..., conditioner): `conditioner` was left as `nothing`. Please provide a non-negative numeric conditioner (e.g. 0.0 or 1.0).",
),
)
end
if !(conditioner isa Number)
throw(
ArgumentError(
"get_natural_manifold_base(::Type{Categorical},..., conditioner): `conditioner` must be a Number, got $(typeof(conditioner)).",
),
)
end
if conditioner < 1
throw(
ArgumentError(
"get_natural_manifold_base(::Type{Categorical},..., conditioner): `conditioner` must be >= 1, got $(conditioner).",
),
)
end
return ProductManifold(Euclidean(conditioner - 1), SinglePointManifold([0.0]))
endcan be rewritten as check_manifold_conditioner(::Type{Categorical}, conditioner::Nothing) = throw(...)
check_manifold_conditioner(::Type{Categorical}, conditioner::Any) = throw(...)
check_manifold_conditioner(::Type{Categorical}, conditioner::Number) = conditioner > 1 ? nothing : throw(...)and then function get_natural_manifold_base(::Type{Categorical}, ::Tuple{}, conditioner=nothing)
check_manifold_conditioner(Categorical, conditioner)
return ProductManifold(Euclidean(conditioner - 1), SinglePointManifold([0.0]))
endor this check can even be placed before the call of the |
partition_point for Binomial, Categorical, NegativeBinomial, Weibull.
Resolves #49
Actually we should check
conditionerin a general way beforeget_natural_manifold_baseorpartition_pointare being called for the individual distributions - should avoid repetitive code.