Skip to content
Open
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
11 changes: 0 additions & 11 deletions R/metrics-interval-range.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ assert_input_interval <- function(observed, lower, upper, interval_range) {
}


#' @title Check that inputs are correct for interval-based forecast
#' @inherit assert_input_interval params description
#' @inherit check_input_sample return description
#' @keywords internal_input_check
check_input_interval <- function(observed, lower, upper, interval_range) {
result <- check_try(
assert_input_interval(observed, lower, upper, interval_range)
)
return(result)
}


#' @title Interval score
#'
Expand Down
11 changes: 0 additions & 11 deletions R/metrics-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ assert_input_quantile <- function(observed, predicted, quantile_level,
return(invisible(NULL))
}

#' @title Check that inputs are correct for quantile-based forecast
#' @inherit assert_input_quantile params description
#' @inherit check_input_sample return description
#' @keywords internal_input_check
check_input_quantile <- function(observed, predicted, quantile_level) {
result <- check_try(
assert_input_quantile(observed, predicted, quantile_level)
)
return(result)
}


#' Weighted interval score (WIS)
#' @description
Expand Down
9 changes: 0 additions & 9 deletions R/metrics-sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ assert_input_sample <- function(observed, predicted) {
return(invisible(NULL))
}

#' @title Check that inputs are correct for sample-based forecast
#' @inherit assert_input_sample params description
#' @inherit document_check_functions return
#' @keywords internal_input_check
check_input_sample <- function(observed, predicted) {
result <- check_try(assert_input_sample(observed, predicted))
return(result)
}


#' @title Determine bias of forecasts
#'
Expand Down
31 changes: 0 additions & 31 deletions man/check_input_interval.Rd

This file was deleted.

31 changes: 0 additions & 31 deletions man/check_input_quantile.Rd

This file was deleted.

27 changes: 0 additions & 27 deletions man/check_input_sample.Rd

This file was deleted.

25 changes: 16 additions & 9 deletions tests/testthat/test-inputs-scoring-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,23 @@ test_that("assert_dims_ok_scalar() works as expected", {


# ==============================================================================
# check_input_sample() # nolint: commented_code_linter
# check_input_sample() removed (issue #684) # nolint: commented_code_linter
# ==============================================================================

test_that("check_input_sample() works as expected", {
# expect no error if dimensions are ok
expect_true(check_input_sample(1:10, matrix(1:20, nrow = 10)))
test_that("assert_input_sample still works after check_input_sample removal", {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this in our tests now this is working? It looks like both of these things are tested elsewhere.

observed <- 1:10
predicted <- matrix(1:20, nrow = 10)
expect_no_condition(assert_input_sample(observed, predicted))
expect_error(assert_input_sample(1:10, 1:11))
})

# expect error if dimensions are not ok
expect_match(
check_input_sample(1:10, 1:11),
"Assertion on 'predicted' failed: Must be of type 'matrix', not 'integer'."
)
test_that("scoring functions still work end-to-end without check_input_* wrappers", {
observed_s <- 1:5
predicted_s <- matrix(rnorm(50), nrow = 5)
observed_q <- 1:5
predicted_q <- matrix(sort(rnorm(25)), nrow = 5)
quantile_level <- c(0.1, 0.25, 0.5, 0.75, 0.9)

expect_no_condition(crps_sample(observed_s, predicted_s))
expect_no_condition(bias_quantile(observed_q, predicted_q, quantile_level))
})
11 changes: 5 additions & 6 deletions tests/testthat/test-metrics-interval-range.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ test_that("assert_input_interval() works as expected", {
})


test_that("check_input_interval() works as expected", {
test_that("assert_input_interval still works after check_input_interval removal", {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same point here do we need this?

expect_no_condition(
check_input_interval(observed, lower, upper, interval_range)
assert_input_interval(observed, lower, upper, interval_range)
)
# expect message return if upper < lower
expect_match(
check_input_interval(observed, upper, lower, interval_range),
regexp = "All values in `upper` need to be greater than or equal"
expect_error(
assert_input_interval(observed, upper, lower, interval_range),
"All values in `upper` need to be greater than or equal"
)
})
24 changes: 9 additions & 15 deletions tests/testthat/test-metrics-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@ forecast_quantile_probs <- c(0.1, 0.25, 0.5, 0.75, 0.9)


# ==============================================================================
# check_input_quantile() # nolint: commented_code_linter
# check_input_quantile() removed (issue #684) # nolint: commented_code_linter
# ==============================================================================
test_that("check_input_quantile() works as expected", {
# expect no error if dimensions are ok
expect_true(
check_input_quantile(
1:10, matrix(1:20, nrow = 10),
quantile_level = c(0.1, 0.9)
)
)

# expect error if dimensions are not ok
expect_match(
check_input_quantile(
test_that("assert_input_quantile still works after check_input_quantile removal", {
observed <- 1:10
predicted <- matrix(1:20, nrow = 10)
quantile_level <- c(0.1, 0.9)
expect_no_condition(assert_input_quantile(observed, predicted, quantile_level))
expect_error(
assert_input_quantile(
1:10, matrix(1:20, nrow = 10),
quantile_level = seq(0.1, 0.9, length.out = 8)
),
"Assertion on 'predicted' failed: Must have exactly 8 cols, but has 2 cols."
)
)
})

Expand Down
Loading