Skip to content

Commit

Permalink
Fix some documentation related warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse committed Oct 28, 2023
1 parent 9006f6a commit 66bb3d3
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 145 deletions.
20 changes: 3 additions & 17 deletions R/check-input-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -394,33 +394,19 @@ check_data_columns <- function(data) {

#' Check whether an attribute is present
#' @description Checks whether an object has an attribute
#' @param data An object to be checked
#' @param object An object to be checked
#' @param attribute name of an attribute to be checked
#' @return Returns TRUE if attribute is there and an error message as
#' a string otherwise
#' @keywords check-inputs
check_has_attribute <- function(object, attribute) {
if (is.null(attr(object, attribute))) {
return(
paste0("Found no attribue `", attribute, "`")
paste0("Found no attribute `", attribute, "`")
)
} else {
return(TRUE)
}
}

#' Test whether an attribute is present
#' @description Tests whether an object has an attribute
#' @param data An object to be checked
#' @return Returns TRUE if attribute is there and FALSE otherwise
#' a string otherwise
#' @keywords check-inputs
test_has_attribute <- function(object, attribute) {
check <- check_has_attribute(object, attribute)
if (is.logical(check)) {
return(TRUE)
} else {
return(FALSE)
}
}


43 changes: 27 additions & 16 deletions R/summarise_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@
#' be used or inferred internally if also not specified. Only one of `across`
#' and `by` may be used at a time.
#' @param fun a function used for summarising scores. Default is `mean`.
#' @param relative_skill logical, whether or not to compute relative
#' performance between models based on pairwise comparisons.
#' If `TRUE` (default is `FALSE`), then a column called
#' 'model' must be present in the input data. For more information on
#' the computation of relative skill, see [pairwise_comparison()].
#' Relative skill will be calculated for the aggregation level specified in
#' `by`.
#' @param relative_skill_metric character with the name of the metric for which
#' a relative skill shall be computed. If equal to 'auto' (the default), then
#' this will be either interval score, CRPS or Brier score (depending on which
#' of these is available in the input data)
#' @param baseline character string with the name of a model. If a baseline is
#' given, then a scaled relative skill with respect to the baseline will be
#' returned. By default (`NULL`), relative skill will not be scaled with
#' respect to a baseline model.
#' @param ... additional parameters that can be passed to the summary function
#' provided to `fun`. For more information see the documentation of the
#' respective function.
Expand Down Expand Up @@ -167,6 +152,33 @@ summarise_scores <- function(scores,
summarize_scores <- summarise_scores



#' @title Add pairwise comparisons
#' @description Adds a columns with relative skills computed by running
#' pairwise comparisons on the scores.
#'
#' a column called
#' 'model' must be present in the input data. For more information on
#' the computation of relative skill, see [pairwise_comparison()].
#' Relative skill will be calculated for the aggregation level specified in
#' `by`.
#' WRITE MORE INFO HERE.
#'
#'
#' @param scores MORE INFO HERE.
#' @param by character vector with column names to summarise scores by. Default
#' is `NULL`, meaning that the only summary that takes is place is summarising
#' over samples or quantiles (in case of quantile-based forecasts), such that
#' there is one score per forecast as defined by the *unit of a single forecast*
#' (rather than one score for every sample or quantile).
#' @param relative_skill_metric character with the name of the metric for which
#' a relative skill shall be computed. If equal to 'auto' (the default), then
#' this will be either interval score, CRPS or Brier score (depending on which
#' of these is available in the input data)
#' @param baseline character string with the name of a model. If a baseline is
#' given, then a scaled relative skill with respect to the baseline will be
#' returned. By default (`NULL`), relative skill will not be scaled with
#' respect to a baseline model.
#' @export
add_pairwise_comparison <- function(scores,
by = NULL,
Expand Down Expand Up @@ -306,7 +318,6 @@ check_summary_params <- function(scores,
#' @description Adds a column with the coverage of central prediction intervals
#' to unsummarised scores as produced by [score()]
#'
#' @details
#' The coverage values that are added are computed according to the values
#' specified in `by`. If, for example, `by = "model"`, then there will be one
#' coverage value for every model and [add_coverage()] will compute the coverage
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ filter_function_args <- function(fun, args) {

#' @title Assign attributes to an object from a named list
#'
#' @description
#' Every list item will be made an attribute of the object.
#' @param object An object to assign attributes to
#' @param attribute_list A named list of attributes to assign to the object.
Expand Down
3 changes: 1 addition & 2 deletions man/add_coverage.Rd

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

43 changes: 43 additions & 0 deletions man/add_pairwise_comparison.Rd

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

6 changes: 1 addition & 5 deletions man/assign_attributes.Rd

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

4 changes: 3 additions & 1 deletion man/check_has_attribute.Rd

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

16 changes: 0 additions & 16 deletions man/check_summary_params.Rd

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

2 changes: 1 addition & 1 deletion man/metrics_sample.Rd

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

45 changes: 2 additions & 43 deletions man/summarise_scores.Rd

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

19 changes: 0 additions & 19 deletions man/test_has_attribute.Rd

This file was deleted.

17 changes: 0 additions & 17 deletions tests/testthat/_snaps/score.md

This file was deleted.

8 changes: 0 additions & 8 deletions tests/testthat/_snaps/summarise_scores.md

This file was deleted.

0 comments on commit 66bb3d3

Please sign in to comment.