From 23b708eb92831f490a36cffa54f6c0f5e709e81d Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Fri, 23 Feb 2024 12:32:13 -0600 Subject: [PATCH] Fix linting issue, update docs --- R/validate.R | 16 +++++++--------- man/as_forecast.Rd | 6 ++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/R/validate.R b/R/validate.R index 307a58249..cc5b02c39 100644 --- a/R/validate.R +++ b/R/validate.R @@ -115,17 +115,15 @@ as_forecast.default <- function(data, } # find forecast type - desired_forecast_type <- forecast_type + desired <- forecast_type forecast_type <- get_forecast_type(data) - if (!is.null(desired_forecast_type)) { - if (forecast_type != desired_forecast_type) { - stop( - "Forecast type determined by scoringutils based on input: `", - forecast_type, - "`. Desired forecast type: `", desired_forecast_type, "`." - ) - } + if (!is.null(desired) && desired != forecast_type) { + stop( + "Forecast type determined by scoringutils based on input: `", + forecast_type, + "`. Desired forecast type: `", desired, "`." + ) } # construct class diff --git a/man/as_forecast.Rd b/man/as_forecast.Rd index fde4b04bd..9e3ed1132 100644 --- a/man/as_forecast.Rd +++ b/man/as_forecast.Rd @@ -10,6 +10,7 @@ as_forecast(data, ...) \method{as_forecast}{default}( data, forecast_unit = NULL, + forecast_type = NULL, observed = NULL, predicted = NULL, model = NULL, @@ -30,6 +31,11 @@ If \code{NULL} (the default), all columns that are not required columns are assumed to form the unit of a single forecast. If specified, all columns that are not part of the forecast unit (or required columns) will be removed.} +\item{forecast_type}{(optional) The forecast type you expect the forecasts +to have. If the forecast type as determined by \code{scoringutils} based on the +input does not match this, an error will be thrown. If \code{NULL} (the default), +the forecast type will be inferred from the data.} + \item{observed}{(optional) Name of the column in \code{data} that contains the observed values. This column will be renamed to "observed".}