Skip to content

Commit

Permalink
fix R cmd check note due to importance_sampling roxygen template
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Nov 10, 2023
1 parent 69fa2f6 commit b85d1eb
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 189 deletions.
49 changes: 24 additions & 25 deletions R/importance_sampling.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' A parent class for different importance sampling methods.
#' @keywords internal
#'
#' @inheritParams psis
#' @param method The importance sampling method to use. The following methods
#' are implemented:
Expand All @@ -8,27 +8,13 @@
#' `sqrt(S)`, where `S` is the number of posterior draws.
#' * [`"sis"`][sis]: Standard Importance Sampling (SIS).
#'
importance_sampling <- function(log_ratios, method, ...) UseMethod("importance_sampling")

#' @noRd
#' @keywords internal
#' @description
#' Currently implemented importance sampling methods
assert_importance_sampling_method_is_implemented <- function(x){
if (!x %in% implemented_is_methods()) {
stop("Importance sampling method '",
x,
"' is not implemented. Implemented methods: '",
paste0(implemented_is_methods, collapse = "', '"),
"'")
}
importance_sampling <- function(log_ratios, method, ...) {
UseMethod("importance_sampling")
}
implemented_is_methods <- function() c("psis", "tis", "sis")

#' Importance sampling of array

#' @rdname importance_sampling
#' @inheritParams psis
#' @template is_method
#' @keywords internal
#' @export
importance_sampling.array <-
function(log_ratios, method,
Expand All @@ -44,10 +30,8 @@ importance_sampling.array <-
do_importance_sampling(log_ratios, r_eff = r_eff, cores = cores, method = method)
}

#' Importance sampling of matrices
#' @rdname importance_sampling
#' @inheritParams psis
#' @template is_method
#' @keywords internal
#' @export
importance_sampling.matrix <-
function(log_ratios, method,
Expand All @@ -61,10 +45,8 @@ importance_sampling.matrix <-
do_importance_sampling(log_ratios, r_eff = r_eff, cores = cores, method = method)
}

#' Importance sampling (default)
#' @rdname importance_sampling
#' @inheritParams psis
#' @template is_method
#' @keywords internal
#' @export
importance_sampling.default <-
function(log_ratios, method, ..., r_eff = NULL) {
Expand Down Expand Up @@ -122,6 +104,23 @@ weights.importance_sampling <-

# internal ----------------------------------------------------------------

#' Validate selected importance sampling method
#' @noRd
#' @keywords internal
#' @description
#' Currently implemented importance sampling methods
assert_importance_sampling_method_is_implemented <- function(x){
if (!x %in% implemented_is_methods()) {
stop("Importance sampling method '",
x,
"' is not implemented. Implemented methods: '",
paste0(implemented_is_methods, collapse = "', '"),
"'")
}
}
implemented_is_methods <- function() c("psis", "tis", "sis")


#' Structure the object returned by the importance_sampling methods
#'
#' @noRd
Expand Down
48 changes: 47 additions & 1 deletion man/importance_sampling.Rd

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

61 changes: 0 additions & 61 deletions man/importance_sampling.array.Rd

This file was deleted.

41 changes: 0 additions & 41 deletions man/importance_sampling.default.Rd

This file was deleted.

61 changes: 0 additions & 61 deletions man/importance_sampling.matrix.Rd

This file was deleted.

0 comments on commit b85d1eb

Please sign in to comment.