Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #562: Reorganise/rename files #705

Merged
merged 14 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 0 additions & 100 deletions R/add_coverage.R

This file was deleted.

78 changes: 0 additions & 78 deletions R/available_forecasts.R

This file was deleted.

41 changes: 0 additions & 41 deletions R/validate.R → R/forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -391,44 +391,3 @@ is_forecast.forecast_point <- function(x, ...) {
is_forecast.forecast_quantile <- function(x, ...) {
inherits(x, "forecast_quantile")
}


#' @title Validate metrics
#'
#' @description This function validates whether the list of metrics is a list
#' of valid functions.
#'
#' The function is used in [score()] to make sure that all metrics are valid
#' functions
#'
#' @param metrics A named list with metrics. Every element should be a scoring
#' function to be applied to the data.
#' @importFrom cli cli_warn
#'
#' @return A named list of metrics, with those filtered out that are not
#' valid functions
#' @importFrom checkmate assert_list test_list check_function
#' @keywords internal_input_check
validate_metrics <- function(metrics) {

assert_list(metrics, min.len = 1, names = "named")

for (i in seq_along(metrics)) {
check_fun <- check_function(metrics[[i]])
if (!is.logical(check_fun)) {
#nolint start: keyword_quote_linter
cli_warn(
c(
"!" = "`Metrics` element number {i} is not a valid function."
)
)
#nolint end
names(metrics)[i] <- "scoringutils_delete"
}
}
metrics[names(metrics) == "scoringutils_delete"] <- NULL

assert_list(metrics, min.len = 1, .var.name = "valid metrics")

return(metrics)
}
Loading