Skip to content

Commit

Permalink
#885 - Delete validate_forecast() (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse authored Sep 30, 2024
1 parent c7bc1be commit 6b004b8
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 68 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export(theme_scoringutils)
export(transform_forecasts)
export(underprediction_quantile)
export(underprediction_sample)
export(validate_forecast)
export(wis)
importFrom(Metrics,ae)
importFrom(Metrics,ape)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<type>()`. 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_<type>()`. 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_<type>()` 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
Expand Down
15 changes: 0 additions & 15 deletions R/forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,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
Expand Down
33 changes: 0 additions & 33 deletions man/validate_forecast.Rd

This file was deleted.

18 changes: 0 additions & 18 deletions tests/testthat/test-forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,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()
# ==============================================================================
Expand Down

0 comments on commit 6b004b8

Please sign in to comment.