Skip to content
Draft
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/check-input-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,4 @@
check <- check_columns_present(data, columns)
return(isTRUE(check))
}

Check warning on line 110 in R/check-input-helpers.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/check-input-helpers.R,line=110,col=1,[trailing_blank_lines_linter] Remove trailing blank lines.
#' Test whether column names are NOT present in a data.frame
#' @description The function checks whether all column names are NOT present.
#' If none of the columns are present, the function returns TRUE. If one or
#' more columns are present, the function returns FALSE.
#' @inheritParams document_check_functions
#' @returns Returns TRUE if none of the columns are present and FALSE otherwise
#' @importFrom checkmate test_names
#' @keywords internal_input_check
test_columns_not_present <- function(data, columns) {
test_names(colnames(data), disjunct.from = columns)
}
5 changes: 3 additions & 2 deletions R/class-forecast-binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ as_forecast_binary.default <- function(data,
#' @export
#' @rdname assert_forecast
#' @importFrom cli cli_abort
#' @importFrom checkmate test_names
#' @keywords validate-forecast-object
assert_forecast.forecast_binary <- function(
forecast, forecast_type = NULL, verbose = TRUE, ...
) {
forecast <- assert_forecast_generic(forecast, verbose)
assert_forecast_type(forecast, actual = "binary", desired = forecast_type)

columns_correct <- test_columns_not_present(
forecast, c("sample_id", "quantile_level")
columns_correct <- test_names(
colnames(forecast), disjunct.from = c("sample_id", "quantile_level")
)
if (!columns_correct) {
#nolint start: keyword_quote_linter
Expand Down
22 changes: 0 additions & 22 deletions man/test_columns_not_present.Rd

This file was deleted.

9 changes: 0 additions & 9 deletions tests/testthat/test-check-input-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ test_that("check_columns_present works", {
)
})

test_that("test_columns_not_present works", {
expect_true(
test_columns_not_present(example_binary, "sample_id")
)
expect_false(
test_columns_not_present(example_binary, "location")
)
})

test_that("check_columns_present() works", {
expect_identical(
check_columns_present(example_quantile, c("observed", "predicted", "nop")),
Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/test-class-forecast-binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ test_that("assert_forecast.forecast_binary works as expected", {
)
})

test_that("assert_forecast.forecast_binary() rejects data with quantile_level column", {
test <- na.omit(as.data.table(example_binary))
test[, "quantile_level" := 0.5]
expect_error(
as_forecast_binary(test),
"Input looks like a binary forecast, but an additional column"
)
})

test_that("assert_forecast.forecast_binary() accepts valid binary data without sample_id or quantile_level", {
expect_no_error(assert_forecast(example_binary))
})

test_that("test_columns_not_present() is no longer exported or defined", {
expect_false(
exists("test_columns_not_present",
where = asNamespace("scoringutils"), mode = "function")
)
})


# ==============================================================================
Expand Down
Loading