Closed nikosbosse closed 3 weeks ago
Some ways in which a forecast
object can become invalid:
model
, observed
, predicted
, quantile_level
...)get_duplicate_forecasts()
would failquantile_level
and a sample_id
column)rbind
additional rows, leading to the same errorNA
value somewhere (meaning they get filtered out)I'm not sure we'd be able to catch all of these immediately. What do you think @Bisaloo @seabbs @sbfnk
Also is this something we should do before the CRAN release, or possibly afterwards?
I am also not sure how we should do this. Suggestions @Bisaloo?
As far as I can tell, all the changes mentioned here are done via [
, or a function that internally uses it (to be confirmed for rbind()
).
So with a custom [.forecast()
method, you should be able to immediately error when the object becomes invalid:
NextMethod()
([.data.frame()
in most/all cases)Also is this something we should do before the CRAN release, or possibly afterwards?
I'd say it's strictly speaking a breaking change but it doesn't really change anything in the API so it can possibly wait.
@Bisaloo would you possibly be willing to take on this PR? I imagine you'd by far be best placed to tackle it.
I'm fully booked until mid-July but could have a go after. Would this work with your timeline?
Yes, that would be perfect, merci beaucoup!
@Bisaloo what does your current schedule look like, would you have a chance to look at this again? Thank you!
I had a quick look last week but got blocked by an infinite loop of functions calling one another.
I'll try to have another look on Friday if possible :crossed_fingers:
Merci!
@Bisaloo what do you think about the next CRAN release? My current understanding is that this is something we should address before the next release, is that right?
I think it's probably slightly better indeed as it's likely to cause subtle breaking changes, which would fit well under 2.0.0.
Note that submission to CRAN is closed for the next two weeks anyways for the summer holiday & maintenance.
A nice additional benefit of this: we can get rid of the function validate_forecast()
. The function is essentially the same as assert_forecast()
, but returns the input data instead of an invisible NULL
.
validate_forecast <- function(forecast, forecast_type = NULL, verbose = TRUE) {
assert_forecast(forecast, forecast_type, verbose)
return(forecast)
}
I think this is done now thanks to @Bisaloo! Please reopen if not fully done.
Originally posted by @Bisaloo in https://github.com/epiforecasts/scoringutils/pull/791#pullrequestreview-2003401135