From cc8cc9d17e24c01dd020dddb6e7bd77ac7e6b8e1 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Tue, 24 Sep 2024 22:17:00 +0200 Subject: [PATCH] delete `validate_forecast()` --- NAMESPACE | 1 - NEWS.md | 2 +- R/forecast.R | 15 --------------- man/validate_forecast.Rd | 33 --------------------------------- tests/testthat/test-forecast.R | 18 ------------------ 5 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 man/validate_forecast.Rd diff --git a/NAMESPACE b/NAMESPACE index e24968a9..ece27fce 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -92,7 +92,6 @@ export(theme_scoringutils) export(transform_forecasts) export(underprediction_quantile) export(underprediction_sample) -export(validate_forecast) export(wis) importFrom(Metrics,ae) importFrom(Metrics,ape) diff --git a/NEWS.md b/NEWS.md index 806b047b..824c9195 100644 --- a/NEWS.md +++ b/NEWS.md @@ -50,7 +50,7 @@ of our [original](https://doi.org/10.48550/arXiv.2205.07090) `scoringutils` pape - The function `interval_score()` was made an internal function rather than being exported to users. We recommend using `wis()` instead. ### (Re-)Validating forecast objects -- To create and validate a new `forecast` object, users can use `as_forecast_()`. To revalidate an existing `forecast` object users can call `assert_forecast()` (which validates the input and returns `invisible(NULL)`. `assert_forecast()` is a generic with methods for the different forecast types. Alternatively, `validate_forecast()` can be used (which calls `assert_forecast()`), which returns the input and is useful in a pipe. Lastly, users can simply print the object to obtain additional information. +- To create and validate a new `forecast` object, users can use `as_forecast_()`. To revalidate an existing `forecast` object users can call `assert_forecast()` (which validates the input and returns `invisible(NULL)`. `assert_forecast()` is a generic with methods for the different forecast types. Alternatively, users can call ``as_forecast_()` again to re-validate a forecast object. Simply printing the object will also provide some additional information. - Users can test whether an object is of class `forecast_*()` using the function `is_forecast()`. Users can also test for a specific `forecast_*` class using the appropriate `is_forecast.forecast_*` method. For example, to check whether an object is of class `forecast_quantile`, you would use you would use `scoringutils:::is_forecast.forecast_quantile()`. ### Pairwise comparisons and relative skill diff --git a/R/forecast.R b/R/forecast.R index 4165d2d7..efbcb6df 100644 --- a/R/forecast.R +++ b/R/forecast.R @@ -502,21 +502,6 @@ assert_forecast.forecast_nominal <- function( } -#' @title Re-validate an existing forecast object -#' -#' @description -#' The function re-validates an existing forecast object. It is similar to -#' [assert_forecast()], but returns the input data instead of an invisible -#' `NULL`. See [as_forecast()] for details on the expected input formats. -#' @inherit assert_forecast params return examples -#' @export -#' @keywords validate-forecast-object -validate_forecast <- function(forecast, forecast_type = NULL, verbose = TRUE) { - assert_forecast(forecast, forecast_type, verbose) - return(forecast) -} - - #' @title Validation common to all forecast types #' #' @description diff --git a/man/validate_forecast.Rd b/man/validate_forecast.Rd deleted file mode 100644 index 8b24513d..00000000 --- a/man/validate_forecast.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/forecast.R -\name{validate_forecast} -\alias{validate_forecast} -\title{Re-validate an existing forecast object} -\usage{ -validate_forecast(forecast, forecast_type = NULL, verbose = TRUE) -} -\arguments{ -\item{forecast}{A forecast object (a validated data.table with predicted and -observed values, see \code{\link[=as_forecast]{as_forecast()}}).} - -\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{verbose}{Logical. If \code{FALSE} (default is \code{TRUE}), no messages and -warnings will be created.} -} -\value{ -Returns \code{NULL} invisibly. -} -\description{ -The function re-validates an existing forecast object. It is similar to -\code{\link[=assert_forecast]{assert_forecast()}}, but returns the input data instead of an invisible -\code{NULL}. See \code{\link[=as_forecast]{as_forecast()}} for details on the expected input formats. -} -\examples{ -forecast <- as_forecast_binary(example_binary) -assert_forecast(forecast) -} -\keyword{validate-forecast-object} diff --git a/tests/testthat/test-forecast.R b/tests/testthat/test-forecast.R index 2ae49880..632a7cda 100644 --- a/tests/testthat/test-forecast.R +++ b/tests/testthat/test-forecast.R @@ -278,24 +278,6 @@ test_that("assert_forecast_generic() works as expected with a data.frame", { }) -# ============================================================================== -# validate_forecast() -# ============================================================================== - -test_that("validate_forecast() works as expected", { - # check that validate forecast returns itself - expect_no_condition( - out <- validate_forecast(as_forecast_point(na.omit(example_point))) - ) - expect_true(!is.null(out)) - - expect_equal( - validate_forecast(as_forecast_point(na.omit(example_point))), - as_forecast_point(na.omit(example_point)) - ) -}) - - # ============================================================================== # new_forecast() # ==============================================================================