Conversation
Distribution constructors now throw a consistent error type based on the nature of the violation: * `DomainError(val, msg)` for numerically invalid parameter values. For relational checks across multiple parameters (e.g. `a < b` in Uniform, `lower ≤ upper` in Censored, `1 ≤ rank ≤ n` in OrderStatistic), the named tuple of related parameters is passed as `err.val` so downstream catchers can identify each value by name. * `DimensionMismatch` for structural size checks in constructors — rows/cols of `M` vs `U`/`V`/`Σ`/`Ω` in `MatrixNormal`/`MatrixTDist`, and length of support vs probability vector in `DiscreteNonParametric`. This matches the idiom already used across the library for `suffstats`/`fit_mle`. * `ArgumentError` is retained only for non-parameter, non-dimension issues (empty data in `fit_mle`, invalid enum in `_char_uplo`, etc.). The `@check_args` macro is collapsed to two `DomainError`-based forms, `(arg, cond, message)` and `(arg, cond)`, both requiring an offending value. The previous no-value forms that fell back to `ArgumentError` have been removed; the macro now errors at expansion time if a caller omits the value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2058 +/- ##
==========================================
- Coverage 86.65% 86.63% -0.02%
==========================================
Files 148 148
Lines 8919 8914 -5
==========================================
- Hits 7729 7723 -6
- Misses 1190 1191 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a numerical estimation problem, I encountered numerical issues resulting in
NaNparameters which then threw aDomainErrorwhen constructing aNormaldistributions. So fine, so good - I could easily handle it by catching and handling theDomainErrorgracefully. Only later I noticed that similar numerical problems withUniformwill lead to anArgumentError.I think it's more convenient and more predictable for downstream users and packages if incorrect/infeasible parameter values always lead to
DomainError.