Skip to content

Commit

Permalink
add initial draft of rename_funs
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanymtang committed Jan 7, 2025
1 parent a51d1f0 commit 085e2e1
Show file tree
Hide file tree
Showing 6 changed files with 639 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export(remove_evaluator)
export(remove_method)
export(remove_vary_across)
export(remove_visualizer)
export(rename_dgps)
export(rename_evaluators)
export(rename_methods)
export(rename_visualizers)
export(render_docs)
export(run_experiment)
export(run_tests)
Expand Down
58 changes: 58 additions & 0 deletions R/experiment-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,64 @@ remove_visualizer <- function(experiment, name = NULL, ...) {
experiment$remove_visualizer(name, ...)
}

#' Helper functions for renaming components in an `Experiment`.
#'
#' @description Helper functions for renaming `DGPs`,
#' `Methods`, `Evaluators`, and `Visualizers` from an
#' `Experiment`. These functions will also rename these objects in the
#' cached documentation and results files.
#'
#' @inheritParams shared_experiment_helpers_args
#' @param ... Named character vector of names to rename. Use
#' `"new_name" = "old_name"` format.
#'
#' @return The original `Experiment` object passed to `remove_*`.
#'
#' @name rename_funs
#' @rdname rename_funs
#'
#' @examples
#' \dontrun{
#' rename_dgps(experiment, "New DGP1" = "DGP1", "New DGP2" = "DGP2")
#' rename_methods(experiment, "New Method1" = "Method1")
#' rename_evaluators(experiment, "New Evaluator1" = "Evaluator1")
#' rename_visualizers(experiment, "New Visualizer1" = "Visualizer1")
#' }
#'
NULL

#' @rdname rename_funs
#'
#' @inherit rename_funs examples
#' @export
rename_dgps <- function(experiment, ...) {
experiment$rename_dgps(...)
}

#' @rdname rename_funs
#'
#' @inherit rename_funs examples
#' @export
rename_methods <- function(experiment, ...) {
experiment$rename_methods(...)
}

#' @rdname rename_funs
#'
#' @inherit rename_funs examples
#' @export
rename_evaluators <- function(experiment, ...) {
experiment$rename_evaluators(...)
}

#' @rdname rename_funs
#'
#' @inherit rename_funs examples
#' @export
rename_visualizers <- function(experiment, ...) {
experiment$rename_visualizers(...)
}

# TODO: add @details
#' Helper functions for getting components in an `Experiment`.
#'
Expand Down
Loading

0 comments on commit 085e2e1

Please sign in to comment.