Issue #447 - Add and simplify more input checks#753
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #753 +/- ##
==========================================
- Coverage 95.31% 95.30% -0.02%
==========================================
Files 21 21
Lines 1602 1598 -4
==========================================
- Hits 1527 1523 -4
Misses 75 75 ☔ View full report in Codecov by Sentry. |
|
I must admit I don't see the value of creating |
R/forecast.R
Outdated
| #' @importFrom data.table copy | ||
| #' @importFrom stats na.omit | ||
| #' @keywords internal | ||
| validate_forecast_internal <- function(data, copy = FALSE, na.omit = FALSE) { |
There was a problem hiding this comment.
as implemented neither of copy or na.omit are ever not true. If we are doing this then why not make these the defaults?
|
All changes aside from the validate_forecast stuff are good to go. In terms of that what about if we had:
|
|
so most uses here would be: forecast <- clean_forecast(forecast)
assert_forecast(forecast, verbose = FALSE)and in the wider world you would do things like: forecast |>
validate_forecast()
score()if you didn't want to copy/convert in |
|
I like that |
|
Only requires some thinking related to the S3 methods. Then, it seems, that This means we would export all three of them, right? |
Yes I think so? Wouldn't we only export validate_forecast and maybe assert_forecast? |
|
Shall we merge this in and address |
Rebase failed
|
I've been going in circles a bit in my head. Latest change: I renamed Further thoughts:
|
Isn't this assert_forecast.
I think replacing two lines of repeated code across functions with an internal function makes a huge amount of sense. |
Yes this would be |
|
Yes I think so. Why can't validate_forecast call assert_forecast (and hence have no duplication)? I also think we can not export |
Yes one should definitely call the other. I'm less concerned about code duplication, but more concerned about exporting a lot of similar functions to the user.
If |
|
It looks like you can keep it internal if you want with a bit fo leg work: https://stackoverflow.com/questions/68515108/internal-s3-generics-with-an-lapply To be honest I am really not clear what the issue is with exporting both as they both have very clear differences? If anything we could get rid of |
Then let's do that. Any preferences re either of the following options?
|
|
no real preference on approach. whatever works/is simplest |
|
I'll merge this now then and make a new PR |
Description
As discussed in #447, some functions lack good input checks. This is the second PR that adds more input checks.
This PR
plot_pairwise_comparisons()- Note: should we rename the first argument fromcomparison_resulttopairwise?plot_pit()validate_forecast_internal()allows creating a copy and omittingNArows (as discussed in Roles ofas_forecast()andvalidate_forecast()#688).forecastobjecttransform_forecasts()get_coverage()get_pit()score().Checklist
lintr::lint_package()to check for style issues introduced by my changes.