diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f2a50448b..cda899829 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -23,7 +23,7 @@ jobs: - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} - - {os: ubuntu-latest, r: '3.5'} + - {os: ubuntu-latest, r: '3.6'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index cde730e6e..95e581a07 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -73,5 +73,5 @@ URL: https://doi.org/10.48550/arXiv.2205.07090, https://epiforecasts.io/scoringu BugReports: https://github.com/epiforecasts/scoringutils/issues VignetteBuilder: knitr Depends: - R (>= 3.5) + R (>= 3.6) Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index e1c061d7d..e6c530dd3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,6 +32,7 @@ export(dispersion) export(dss_sample) export(get_duplicate_forecasts) export(get_forecast_unit) +export(get_forecast_type) export(interval_coverage_deviation_quantile) export(interval_coverage_quantile) export(interval_coverage_sample) @@ -86,6 +87,7 @@ importFrom(checkmate,assert_list) importFrom(checkmate,assert_logical) importFrom(checkmate,assert_number) importFrom(checkmate,assert_numeric) +importFrom(checkmate,assert_vector) importFrom(checkmate,check_atomic_vector) importFrom(checkmate,check_data_frame) importFrom(checkmate,check_function) diff --git a/R/check-inputs-scoring-functions.R b/R/check-inputs-scoring-functions.R index 0e4467e3c..2c36071ad 100644 --- a/R/check-inputs-scoring-functions.R +++ b/R/check-inputs-scoring-functions.R @@ -161,25 +161,21 @@ check_input_interval <- function(observed, lower, upper, range) { #' that `predicted` represents the probability that the observed value is equal #' to the highest factor level. #' @param predicted Input to be checked. `predicted` should be a vector of -#' length n, holding probabilities. Values represent the probability that +#' length n, holding probabilities. Alternatively, `predicted` can be a matrix +#' of size n x 1. Values represent the probability that #' the corresponding value in `observed` will be equal to the highest #' available factor level. #' @importFrom checkmate assert assert_factor #' @inherit document_assert_functions return #' @keywords check-inputs assert_input_binary <- function(observed, predicted) { - if (length(observed) != length(predicted)) { - stop("`observed` and `predicted` need to be ", - "of same length when scoring binary forecasts") - } - assert_factor(observed, n.levels = 2) - levels <- levels(observed) - assert( - check_numeric_vector(predicted, min.len = 1, lower = 0, upper = 1) - ) + assert_factor(observed, n.levels = 2, min.len = 1) + assert_numeric(predicted, lower = 0, upper = 1) + assert_dims_ok_point(observed, predicted) return(invisible(NULL)) } + #' @title Check that inputs are correct for binary forecast #' @inherit assert_input_binary params description #' @inherit document_check_functions return @@ -200,12 +196,9 @@ check_input_binary <- function(observed, predicted) { #' @inherit document_assert_functions return #' @keywords check-inputs assert_input_point <- function(observed, predicted) { - assert(check_numeric_vector(observed, min.len = 1)) - assert(check_numeric_vector(predicted, min.len = 1)) - if (length(observed) != length(predicted)) { - stop("`observed` and `predicted` need to be ", - "of same length when scoring point forecasts") - } + assert(check_numeric(observed)) + assert(check_numeric(predicted)) + assert(check_dims_ok_point(observed, predicted)) return(invisible(NULL)) } @@ -217,3 +210,48 @@ check_input_point <- function(observed, predicted) { result <- check_try(assert_input_point(observed, predicted)) return(result) } + + +#' @title Assert Inputs Have Matching Dimensions +#' @description Function assesses whether input dimensions match. In the +#' following, n is the number of observations / forecasts. Scalar values may +#' be repeated to match the length of the other input. +#' Allowed options are therefore +#' - `observed` is vector of length 1 or length n +#' - `predicted` is +#' - a vector of of length 1 or length n +#' - a matrix with n rows and 1 column +#' @inherit assert_input_binary +#' @inherit document_assert_functions return +#' @importFrom checkmate assert_vector check_matrix check_vector assert +#' @keywords check-inputs +assert_dims_ok_point <- function(observed, predicted) { + assert_vector(observed, min.len = 1) + n_obs <- length(observed) + assert( + check_vector(predicted, min.len = 1, strict = TRUE), + check_matrix(predicted, ncols = 1, nrows = n_obs) + ) + dim_p <- dim(predicted) + if (!is.null(dim_p) && (length(dim_p) > 1) && (dim_p[2] > 1)) { + stop("`predicted` must be a vector or a matrix with one column. Found ", + dim(predicted)[2], " columns") + } + n_pred <- length(as.vector(predicted)) + # check that both are either of length 1 or of equal length + if ((n_obs != 1) && (n_pred != 1) && (n_obs != n_pred)) { + stop("`observed` and `predicted` must either be of length 1 or ", + "of equal length. Found ", n_obs, " and ", n_pred) + } + return(invisible(NULL)) +} + + +#' @title Check Inputs Have Matching Dimensions +#' @inherit assert_dims_ok_point params description +#' @inherit document_check_functions return +#' @keywords check-inputs +check_dims_ok_point <- function(observed, predicted) { + result <- check_try(assert_dims_ok_point(observed, predicted)) + return(result) +} diff --git a/R/correlations.R b/R/correlations.R index 75eda7583..0a553e8a7 100644 --- a/R/correlations.R +++ b/R/correlations.R @@ -21,8 +21,6 @@ correlation <- function(scores, metrics = NULL, digits = NULL) { - metrics <- check_metrics(metrics) - metrics <- get_metrics(scores) # if quantile column is present, throw a warning diff --git a/R/get_-functions.R b/R/get_-functions.R index 459ee9818..569fe8382 100644 --- a/R/get_-functions.R +++ b/R/get_-functions.R @@ -1,19 +1,27 @@ # Functions that help to obtain information about the data -#' @title Infer the type of a forecast based on a data.frame +#' @title Infer Forecast Type +#' @description Helper function to infer the forecast type based on a +#' data.frame or similar with predictions. Please check the vignettes to +#' learn more about forecast types. #' -#' @description Internal helper function to get the type of the forecast. -#' Options are "sample-based", "quantile-based", "binary" or "point" forecast. -#' The function runs additional checks to make sure the data satisfies -#' requirements and throws an informative error if any issues are found. -#' -#' @inheritParams validate +#' Possible forecast types are +#' - "sample-based" +#' - "quantile-based" +#' - "binary" +#' - "point" forecast. #' +#' The function runs additional checks to make sure the data satisfies the +#' requirements of the respective forecast type and throws an +#' informative error if any issues are found. +#' @inheritParams score #' @return Character vector of length one with either "binary", "quantile", #' "sample" or "point". -#' -#' @keywords internal +#' @export +#' @keywords check-forceasts get_forecast_type <- function(data) { + assert_data_frame(data) + assert(check_columns_present(data, c("observed", "predicted"))) if (test_forecast_type_is_binary(data)) { forecast_type <- "binary" } else if (test_forecast_type_is_quantile(data)) { @@ -24,8 +32,8 @@ get_forecast_type <- function(data) { forecast_type <- "point" } else { stop( - "Checking `data`: input doesn't satisfy criteria for any forecast type.", - "Are you missing a column `quantile` or `sample_id`?", + "Checking `data`: input doesn't satisfy criteria for any forecast type. ", + "Are you missing a column `quantile` or `sample_id`? ", "Please check the vignette for additional info." ) } diff --git a/man/assert_dims_ok_point.Rd b/man/assert_dims_ok_point.Rd new file mode 100644 index 000000000..4f6bd3bd0 --- /dev/null +++ b/man/assert_dims_ok_point.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/check-inputs-scoring-functions.R +\name{assert_dims_ok_point} +\alias{assert_dims_ok_point} +\title{Assert Inputs Have Matching Dimensions} +\usage{ +assert_dims_ok_point(observed, predicted) +} +\arguments{ +\item{observed}{Input to be checked. Should be a factor of length n with +exactly two levels, holding the observed values. +The highest factor level is assumed to be the reference level. This means +that \code{predicted} represents the probability that the observed value is equal +to the highest factor level.} + +\item{predicted}{Input to be checked. \code{predicted} should be a vector of +length n, holding probabilities. Alternatively, \code{predicted} can be a matrix +of size n x 1. Values represent the probability that +the corresponding value in \code{observed} will be equal to the highest +available factor level.} +} +\value{ +Returns NULL invisibly if the assertion was successful and throws an +error otherwise. +} +\description{ +Function assesses whether input dimensions match. In the +following, n is the number of observations / forecasts. Scalar values may +be repeated to match the length of the other input. +Allowed options are therefore +\itemize{ +\item \code{observed} is vector of length 1 or length n +\item \code{predicted} is +\itemize{ +\item a vector of of length 1 or length n +\item a matrix with n rows and 1 column +} +} +} +\keyword{check-inputs} diff --git a/man/assert_input_binary.Rd b/man/assert_input_binary.Rd index 4ca8f7883..5b4d8b2bf 100644 --- a/man/assert_input_binary.Rd +++ b/man/assert_input_binary.Rd @@ -14,7 +14,8 @@ that \code{predicted} represents the probability that the observed value is equa to the highest factor level.} \item{predicted}{Input to be checked. \code{predicted} should be a vector of -length n, holding probabilities. Values represent the probability that +length n, holding probabilities. Alternatively, \code{predicted} can be a matrix +of size n x 1. Values represent the probability that the corresponding value in \code{observed} will be equal to the highest available factor level.} } diff --git a/man/check_dims_ok_point.Rd b/man/check_dims_ok_point.Rd new file mode 100644 index 000000000..1269a6725 --- /dev/null +++ b/man/check_dims_ok_point.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/check-inputs-scoring-functions.R +\name{check_dims_ok_point} +\alias{check_dims_ok_point} +\title{Check Inputs Have Matching Dimensions} +\usage{ +check_dims_ok_point(observed, predicted) +} +\arguments{ +\item{observed}{Input to be checked. Should be a factor of length n with +exactly two levels, holding the observed values. +The highest factor level is assumed to be the reference level. This means +that \code{predicted} represents the probability that the observed value is equal +to the highest factor level.} + +\item{predicted}{Input to be checked. \code{predicted} should be a vector of +length n, holding probabilities. Alternatively, \code{predicted} can be a matrix +of size n x 1. Values represent the probability that +the corresponding value in \code{observed} will be equal to the highest +available factor level.} +} +\value{ +Returns TRUE if the check was successful and a string with an +error message otherwise +} +\description{ +Function assesses whether input dimensions match. In the +following, n is the number of observations / forecasts. Scalar values may +be repeated to match the length of the other input. +Allowed options are therefore +\itemize{ +\item \code{observed} is vector of length 1 or length n +\item \code{predicted} is +\itemize{ +\item a vector of of length 1 or length n +\item a matrix with n rows and 1 column +} +} +} +\keyword{check-inputs} diff --git a/man/check_input_binary.Rd b/man/check_input_binary.Rd index 5b206f35b..10d6c36ea 100644 --- a/man/check_input_binary.Rd +++ b/man/check_input_binary.Rd @@ -14,7 +14,8 @@ that \code{predicted} represents the probability that the observed value is equa to the highest factor level.} \item{predicted}{Input to be checked. \code{predicted} should be a vector of -length n, holding probabilities. Values represent the probability that +length n, holding probabilities. Alternatively, \code{predicted} can be a matrix +of size n x 1. Values represent the probability that the corresponding value in \code{observed} will be equal to the highest available factor level.} } diff --git a/man/get_forecast_type.Rd b/man/get_forecast_type.Rd index a923baa80..19d52d2b3 100644 --- a/man/get_forecast_type.Rd +++ b/man/get_forecast_type.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/get_-functions.R \name{get_forecast_type} \alias{get_forecast_type} -\title{Infer the type of a forecast based on a data.frame} +\title{Infer Forecast Type} \usage{ get_forecast_type(data) } @@ -14,9 +14,20 @@ Character vector of length one with either "binary", "quantile", "sample" or "point". } \description{ -Internal helper function to get the type of the forecast. -Options are "sample-based", "quantile-based", "binary" or "point" forecast. -The function runs additional checks to make sure the data satisfies -requirements and throws an informative error if any issues are found. +Helper function to infer the forecast type based on a +data.frame or similar with predictions. Please check the vignettes to +learn more about forecast types. + +Possible forecast types are +\itemize{ +\item "sample-based" +\item "quantile-based" +\item "binary" +\item "point" forecast. } -\keyword{internal} + +The function runs additional checks to make sure the data satisfies the +requirements of the respective forecast type and throws an +informative error if any issues are found. +} +\keyword{check-forceasts} diff --git a/tests/testthat/test-get_-functions.R b/tests/testthat/test-get_-functions.R index 532574a14..d395d35a1 100644 --- a/tests/testthat/test-get_-functions.R +++ b/tests/testthat/test-get_-functions.R @@ -162,3 +162,39 @@ test_that("get_duplicate_forecasts() works as expected for point", { 22 ) }) + + +# ============================================================================== +# `get_forecast_type` +# ============================================================================== +test_that("get_forecast_type() works as expected", { + expect_equal(get_forecast_type(as.data.frame(example_quantile)), "quantile") + expect_equal(get_forecast_type(example_continuous), "sample") + expect_equal(get_forecast_type(example_integer), "sample") + expect_equal(get_forecast_type(example_binary), "binary") + expect_equal(get_forecast_type(example_point), "point") + + expect_error( + get_forecast_type(data.frame(x = 1:10)), + "Assertion on 'data' failed: Columns 'observed', 'predicted' not found in data.", + fixed = TRUE + ) + + df <- data.frame(observed = 1:10, predicted = factor(1:10)) + expect_error( + get_forecast_type(df), + "Checking `data`: input doesn't satisfy criteria for any forecast type. Are you missing a column `quantile` or `sample_id`? Please check the vignette for additional info.", + fixed = TRUE + ) + + data <- validate(example_integer) + attr(data, "forecast_type") <- "binary" + expect_warning( + get_forecast_type(data), + "Object has an attribute `forecast_type`, but it looks different from what's expected based on the data. +Existing: binary +Expected: sample +Running `validate()` again might solve the problem", + fixed = TRUE + ) +}) diff --git a/tests/testthat/test-metrics-binary.R b/tests/testthat/test-metrics-binary.R index 9c49e7050..79f56c535 100644 --- a/tests/testthat/test-metrics-binary.R +++ b/tests/testthat/test-metrics-binary.R @@ -7,121 +7,158 @@ df <- data.table( id = 1:10 ) -# test input handling -test_that("function throws an error when missing observed or predicted", { - observed <- sample(c(0, 1), size = 10, replace = TRUE) - predicted <- replicate( - 20, - sample(c(0, 1), size = 10, replace = TRUE) - ) +observed_point <- rnorm(10) +predicted_point <- rnorm(10) - expect_error( - brier_score(predicted = predicted), - 'argument "observed" is missing, with no default' - ) +# ============================================================================== +# Test Input Checks - this also checks point inputs where functions are similar +# ============================================================================== +test_that("correct input works", { + expect_no_condition(assert_input_binary(observed, predicted)) + expect_no_condition(assert_input_point(observed_point, predicted_point)) - expect_error( - brier_score(observed = observed), - 'argument "predicted" is missing, with no default' + # observed is a single number and does not have the same length as predicted + expect_no_condition( + assert_input_binary(factor(1, levels = c(0, 1)), predicted) + ) + expect_no_condition( + assert_input_point(1, predicted_point) ) -}) - + # predicted is a single number and does not have the same length as observed + expect_no_condition(assert_input_binary(observed, predicted = 0.2)) + expect_no_condition(assert_input_point(observed_point, predicted = 0.2)) -test_that("function throws an error for wrong format of `observed`", { - observed <- factor(rpois(10, lambda = 1:10)) - predicted <- runif(10, min = 0, max = 1) + # predicted is a matrix with nrow equal to observed + expect_no_condition(assert_input_binary(observed, matrix(predicted))) + expect_no_condition(assert_input_point(observed_point, matrix(predicted_point))) +}) +# test input handling +test_that("function throws an error for wrong input formats", { + # observed value not as expected expect_error( - brier_score( - observed = observed, - predicted = predicted - ), - "Assertion on 'observed' failed: Must have exactly 2 levels." + assert_input_binary(observed = rnorm(10), predicted = predicted), + "Assertion on 'observed' failed: Must be of type 'factor', not 'double'." ) - - observed <- rnorm(10) expect_error( - brier_score( - observed = observed, - predicted = predicted - ), - "Assertion on 'observed' failed: Must be of type 'factor', not 'double'." + assert_input_binary(1:10, predicted), + "Assertion on 'observed' failed: Must be of type 'factor', not 'integer'." ) -}) - -test_that("function throws an error for wrong format of predictions", { - predicted <- runif(10, min = 0, max = 1) expect_error( - brier_score( - observed = observed, - predicted = as.list(predicted) - ), + assert_input_binary(observed = observed, predicted = as.list(predicted)), + "Assertion on 'predicted' failed: Must be of type 'numeric', not 'list'." + ) + expect_error( + assert_input_point(observed = factor(rnorm(10)), predicted = predicted), + "Assertion on 'observed' failed: Must be of type 'numeric', not 'factor'." + ) + expect_error( + assert_input_point(observed = observed_point, list(predicted_point)), "Assertion on 'predicted' failed: Must be of type 'numeric', not 'list'." ) - predicted <- runif(15, min = 0, max = 1) + # observed value has not 2 levels expect_error( - brier_score( - observed = observed, - predicted = predicted - ), - "`observed` and `predicted` need to be of same length when scoring binary forecasts", - # "Arguments to the following function call: 'brier_score(observed = observed, predicted = predicted)' should have the same length (or length one). Actual lengths: 10, 15", - fixed = TRUE + assert_input_binary(factor(1:10), predicted), + "Assertion on 'observed' failed: Must have exactly 2 levels." ) -}) -test_that("Input checking for binary forecasts works", { - # everything correct - expect_no_condition( - scoringutils:::assert_input_binary(observed, predicted) + # wrong length + expect_error( + assert_input_binary(observed = observed, predicted = runif(15, min = 0, max = 1)), + "`observed` and `predicted` must either be of length 1 or of equal length. Found 10 and 15", + fixed = TRUE + ) + expect_error( + assert_input_point(observed_point, runif(15, min = 0, max = 1)), + "Assertion on 'observed' failed: `observed` and `predicted` must either be of length 1 or of equal length. Found 10 and 15.", + fixed = TRUE ) # predicted > 1 expect_error( - scoringutils:::assert_input_binary(observed, predicted + 1), + assert_input_binary(observed, predicted + 1), "Assertion on 'predicted' failed: Element 1 is not <= 1." ) # predicted < 0 expect_error( - scoringutils:::assert_input_binary(observed, predicted - 1), + assert_input_binary(observed, predicted - 1), "Assertion on 'predicted' failed: Element 1 is not >= 0." ) - # observed value not factor + # predicted is a matrix with one row expect_error( - scoringutils:::assert_input_binary(1:10, predicted), - "Assertion on 'observed' failed: Must be of type 'factor', not 'integer'." + assert_input_binary(observed, predicted = matrix(0.2)), + "Assertion failed. One of the following must apply:\n * check_vector(predicted): Must be of type 'vector', not 'matrix'\n * check_matrix(predicted): Must have exactly 10 rows, but has 1 rows", + fixed = TRUE) + expect_error( + assert_input_point(observed_point, predicted = matrix(0.2)), + "Assertion failed. One of the following must apply:\n * check_vector(predicted): Must be of type 'vector', not 'matrix'\n * check_matrix(predicted): Must have exactly 10 rows, but has 1 rows", + fixed = TRUE) + + # predicted is a matrix with 2 rows + expect_error( + assert_input_binary(observed, matrix(rep(predicted, 2), ncol = 2)), + "Assertion failed. One of the following must apply:\n * check_vector(predicted): Must be of type 'vector', not 'matrix'\n * check_matrix(predicted): Must have exactly 1 cols, but has 2 cols", + fixed = TRUE ) +}) - # observed value has not 2 levels + +# ============================================================================== +# Test Binary Metrics +# ============================================================================== + +test_that("function throws an error when missing observed or predicted", { expect_error( - scoringutils:::assert_input_binary(factor(1:10), predicted), - "Assertion on 'observed' failed: Must have exactly 2 levels." + brier_score(predicted = predicted), + 'argument "observed" is missing, with no default' ) + expect_error( + brier_score(observed = observed), + 'argument "predicted" is missing, with no default' + ) +}) + +test_that("Brier score works with different inputs", { # observed is a single number and does not have the same length as predicted + expect_equal( + brier_score(factor(1, levels = c(0, 1)), predicted), + (1 - predicted)^2 + ) + + # predicted is a single number and does not have the same length as observed + expect_equal( + brier_score(observed, predicted = 0.2), + ifelse(observed == 1, (1 - 0.2)^2, (0.2)^2) + ) + + # predicted is a matrix with 1 row expect_error( - scoringutils:::assert_input_binary(factor(1), predicted), - "`observed` and `predicted` need to be of same length when scoring binary forecasts", + brier_score(observed, predicted = matrix(0.2)), + "Assertion failed. One of the following must apply:\n * check_vector(predicted): Must be of type 'vector', not 'matrix'\n * check_matrix(predicted): Must have exactly 10 rows, but has 1 rows", fixed = TRUE ) - # predicted is a matrix + # predicted is an array expect_error( - scoringutils:::assert_input_binary(observed, matrix(predicted)), - "Assertion on 'predicted' failed: Must be of type 'atomic vector', not 'matrix'." + brier_score(observed, predicted = array(0.2)), + "Assertion failed. One of the following must apply:\n * check_vector(predicted): Must be of type 'vector', not 'array'\n * check_matrix(predicted): Must be of type 'matrix', not 'array'", + fixed = TRUE ) }) + test_that("Binary metrics work within and outside of `score()`", { result <- score(df) expect_equal( brier_score(observed, predicted), result$brier_score ) + expect_equal( logs_binary(observed, predicted), result$log_score diff --git a/tests/testthat/test-plot_correlation.R b/tests/testthat/test-plot_correlation.R index be29faf3b..0b170b963 100644 --- a/tests/testthat/test-plot_correlation.R +++ b/tests/testthat/test-plot_correlation.R @@ -1,5 +1,5 @@ test_that("plot_correlation() works as expected", { - correlations <- correlation(summarise_scores(scores), digits = 2) + correlations <- correlation(summarise_scores(scores_quantile), digits = 2) p <- plot_correlation(correlations) expect_s3_class(p, "ggplot") skip_on_cran() diff --git a/tests/testthat/test-plot_interval_coverage.R b/tests/testthat/test-plot_interval_coverage.R index 0e885219f..5ff1fbf98 100644 --- a/tests/testthat/test-plot_interval_coverage.R +++ b/tests/testthat/test-plot_interval_coverage.R @@ -1,5 +1,5 @@ test_that("plot_interval_coverage() works as expected", { - coverage <- add_coverage(example_quantile) |> + coverage <- add_coverage(example_quantile) %>% summarise_scores(by = c("model", "range")) p <- plot_interval_coverage(coverage) expect_s3_class(p, "ggplot") diff --git a/tests/testthat/test-plot_quantile_coverage.R b/tests/testthat/test-plot_quantile_coverage.R index 060b9be26..1851ccb5c 100644 --- a/tests/testthat/test-plot_quantile_coverage.R +++ b/tests/testthat/test-plot_quantile_coverage.R @@ -1,5 +1,5 @@ test_that("plot_quantile_coverage() works as expected", { - coverage <- add_coverage(example_quantile) |> + coverage <- add_coverage(example_quantile) %>% summarise_scores(by = c("model", "quantile")) p <- plot_quantile_coverage(coverage) diff --git a/tests/testthat/test-plot_ranges.R b/tests/testthat/test-plot_ranges.R index b4dec124e..9a18cffe3 100644 --- a/tests/testthat/test-plot_ranges.R +++ b/tests/testthat/test-plot_ranges.R @@ -1,8 +1,8 @@ m <- modifyList(metrics_no_cov_no_ae, list("bias" = NULL)) sum_scores <- copy(example_quantile) %>% - .[, interval_range := scoringutils:::get_range_from_quantile(quantile)] |> - score(metrics = m) |> + .[, interval_range := scoringutils:::get_range_from_quantile(quantile)] %>% + score(metrics = m) %>% summarise_scores(by = c("model", "target_type", "interval_range")) sum_scores[, range := interval_range]