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

Applying code suggestions from code review #806

Merged
merged 8 commits into from
May 6, 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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Authors@R: c(
family = "Bosse",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "https://orcid.org/0000-0002-7750-5280")),
comment = c(ORCID = "0000-0002-7750-5280")),
person(given = "Sam Abbott",
role = c("aut"),
email = "[email protected]",
Expand All @@ -16,7 +16,7 @@ Authors@R: c(
family = "Gruson",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "https://orcid.org/0000-0002-4094-1476")),
comment = c(ORCID = "0000-0002-4094-1476")),
person(given = "Johannes Bracher",
role = c("ctb"),
email = "[email protected]",
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ importFrom(checkmate,assert_factor)
importFrom(checkmate,assert_function)
importFrom(checkmate,assert_list)
importFrom(checkmate,assert_logical)
importFrom(checkmate,assert_matrix)
importFrom(checkmate,assert_number)
importFrom(checkmate,assert_numeric)
importFrom(checkmate,assert_subset)
Expand All @@ -108,6 +109,7 @@ importFrom(checkmate,check_set_equal)
importFrom(checkmate,check_vector)
importFrom(checkmate,test_factor)
importFrom(checkmate,test_list)
importFrom(checkmate,test_names)
importFrom(checkmate,test_numeric)
importFrom(checkmate,test_subset)
importFrom(cli,cli_abort)
Expand Down
3 changes: 2 additions & 1 deletion R/check-input-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ test_columns_present <- function(data, columns) {
#' more columns are present, the function returns FALSE.
#' @inheritParams document_check_functions
#' @return 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) {
checkmate::test_names(colnames(data), disjunct.from = columns)
test_names(colnames(data), disjunct.from = columns)
}
2 changes: 1 addition & 1 deletion R/check-inputs-scoring-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' N (number of columns) the number of samples per forecast.
#' If `observed` is just a single number, then predicted values can just be a
#' vector of size N.
#' @importFrom checkmate assert assert_numeric check_matrix
#' @importFrom checkmate assert assert_numeric check_matrix assert_matrix
#' @inherit document_assert_functions params return
#' @keywords internal_input_check
assert_input_sample <- function(observed, predicted) {
Expand Down
1 change: 0 additions & 1 deletion R/correlations.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ get_correlations <- function(scores,
return(correlations[])
}

# define function to obtain upper triangle of matrix
get_lower_tri <- function(cormat) {
cormat[lower.tri(cormat)] <- NA
return(cormat)
Expand Down
2 changes: 1 addition & 1 deletion R/summarise_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ summarise_scores <- function(scores,

# if across is provided, calculate new `by`
if (!is.null(across)) {
if (by != "model") {
if (!setequal(by, "model")) {
warning("You specified `across` and `by` at the same time.",
"`by` will be ignored.")
}
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ forecast_quantile <- example_quantile |>
#> unexpected.

print(forecast_quantile, 2)
#> Forecast type:
#> quantile
#> Forecast type: quantile
#> Forecast unit:
#> location, forecast_date, target_end_date, target_type, model, and horizon
#>
Expand Down
2 changes: 1 addition & 1 deletion man/scoringutils-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/testthat/test-summarise_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,12 @@ test_that("summarise_scores() across argument works as expected", {
scores, by = c("location", "target_type")
)
)

expect_warning(
summarise_scores(
scores, across = c("horizon", "model", "forecast_date", "target_end_date"),
by = c("model", "target_type")
),
"You specified `across` and `by` at the same time.`by` will be ignored"
)
})