Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all instances of StatsError with custom error types or Option<T> #284

Merged
merged 8 commits into from
Sep 12, 2024

Conversation

FreezyLemon
Copy link
Contributor

Closes #221, I think.

Added some new error types similar to the ones introduced in #265.

Some functions only got the simpler Option<T> return type if they only have one error condition. The functions in MultivariateNormal also have a simple Option return type because they're non-public, and it's expected that the preconditions are fulfilled on every call anyways. No need for fancy error messages (and can be easily changed if need be)

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 81.42857% with 26 lines in your changes missing coverage. Please review.

Project coverage is 93.94%. Comparing base (1f8e00a) to head (e87cde0).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/function/beta.rs 84.88% 13 Missing ⚠️
src/function/gamma.rs 70.58% 5 Missing ⚠️
src/statistics/iter_statistics.rs 0.00% 4 Missing ⚠️
src/function/exponential.rs 57.14% 3 Missing ⚠️
src/distribution/multivariate_normal.rs 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #284      +/-   ##
==========================================
+ Coverage   93.75%   93.94%   +0.19%     
==========================================
  Files          53       52       -1     
  Lines       11800    11783      -17     
==========================================
+ Hits        11063    11070       +7     
+ Misses        737      713      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@YeungOnion
Copy link
Contributor

I would drop 9fa380a since we'll go with a panic only in #278 since it's internal.

@YeungOnion
Copy link
Contributor

Wondering if it's valuable to emit a Result<f64, ValueWithConvergence{value: f64, rel_tol: f64}> to describe what convergence was like at the final iteration, or perhaps that would make sense as a part of returning values that emit precision as well as converged value.

@FreezyLemon
Copy link
Contributor Author

FreezyLemon commented Sep 10, 2024

I would drop 9fa380a since we'll go with a panic only in #278 since it's internal.

I'll leave this PR as-is for now and update it then.. If i revert any of the changes here then I also have to revert the removal of StatsError, which is kind of the end goal of this

Wondering if it's valuable to emit a Result<f64, ValueWithConvergence{value: f64, rel_tol: f64}> to describe what convergence was like at the final iteration

Maybe. I'd say it's a bit out of scope for this PR though, might make sense to open an issue for it

@YeungOnion
Copy link
Contributor

I'll leave this PR as-is for now and update it then.. If i revert any of the changes here then I also have to revert the removal of StatsError, which is kind of the end goal of this

that makes sense, odd that deleting error.rs was a conflict, but I did the rebase locally and merged that last commit removing it.

@YeungOnion YeungOnion merged commit a40ba07 into statrs-dev:master Sep 12, 2024
9 of 11 checks passed
@FreezyLemon FreezyLemon deleted the remove-statserror branch September 12, 2024 21:53
@FreezyLemon
Copy link
Contributor Author

@YeungOnion Not sure what happened, but error.rs was not deleted in the last commit. Maybe something went wrong during the rebase?

@YeungOnion
Copy link
Contributor

Presumably, the commit I force pushed added it back into the tree 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider improving error handling and StatsError type
2 participants