Skip to content

Commit 1d4b2a0

Browse files
committed
rename all edits to debug
1 parent f2b4569 commit 1d4b2a0

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

R/runSimulation.R

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@
319319
#' will automatically be detected and read-in. Upon completion, the final results will
320320
#' be saved to the working directory, and the temp file will be removed. Default is \code{FALSE}
321321
#'
322-
#' @param edit a string indicating where to initiate a \code{browser()} call for editing and debugging.
322+
#' @param debug a string indicating where to initiate a \code{browser()} call for editing and debugging.
323323
#' General options are \code{'none'} (default; no debugging), \code{'error'}, which starts the debugger
324324
#' when any error in the code is detected in one of three generate-analyse-summarise functions,
325325
#' and \code{'all'}, which debugs all the user defined functions regardless of whether an error was thrown
326326
#' or not. Specific options include: \code{'generate'}
327-
#' to edit the data simulation function, \code{'analyse'} to edit the computational function, and
328-
#' \code{'summarise'} to edit the aggregation function.
327+
#' to debug the data simulation function, \code{'analyse'} to debug the computational function, and
328+
#' \code{'summarise'} to debug the aggregation function.
329329
#'
330330
#' Alternatively, users may place \code{\link{browser}} calls within the respective functions for
331331
#' debugging at specific lines, which is useful when debugging based on conditional evaluations (e.g.,
@@ -552,7 +552,7 @@
552552
#' ## ls() to see what has been defined, and type Q to quit the debugger
553553
#' runSimulation(design=Design, replications=1000,
554554
#' generate=Generate, analyse=Analyse, summarise=Summarise,
555-
#' parallel=TRUE, edit='generate')
555+
#' parallel=TRUE, debug='generate')
556556
#'
557557
#' ## Alternatively, place a browser() within the desired function line to
558558
#' ## jump to a specific location
@@ -646,7 +646,7 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
646646
warnings_as_errors = FALSE, save_seeds = FALSE, load_seed = NULL,
647647
parallel = FALSE, ncores = parallel::detectCores(), cl = NULL, MPI = FALSE,
648648
max_errors = 50L, as.factor = TRUE, save_generate_data = FALSE,
649-
save_details = list(), edit = 'none', progress = TRUE,
649+
save_details = list(), debug = 'none', progress = TRUE,
650650
allow_na = FALSE, allow_nan = FALSE, verbose = TRUE)
651651
{
652652
stopifnot(!missing(analyse))
@@ -688,7 +688,7 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
688688
}
689689
if(!is.null(cl)) parallel <- TRUE
690690
if(!is.null(load_seed)) seed <- NULL
691-
edit <- tolower(edit)
691+
debug <- tolower(debug)
692692
summarise_asis <- FALSE
693693
if(missing(summarise)){
694694
summarise <- function(condition, results, fixed_objects = NULL) results
@@ -709,7 +709,7 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
709709
stopifnot(!missing(replications))
710710
if(!is.null(seed))
711711
stopifnot(nrow(design) == length(seed))
712-
edit <- tolower(edit)
712+
debug <- tolower(debug)
713713
if(!save && any(save_results, save_generate_data, save_seeds)) filename <- NULL
714714
for(i in names(Functions)){
715715
fms <- names(formals(Functions[[i]]))
@@ -750,34 +750,26 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
750750
stop('design must be a data.frame object', call. = FALSE)
751751
if(replications < 1L)
752752
stop('number of replications must be greater than or equal to 1', call. = FALSE)
753-
if(!(edit %in% c('none', 'analyse', 'generate', 'summarise', 'all', 'recover', 'error')))
754-
stop('edit location is not valid', call. = FALSE)
753+
if(!(debug %in% c('none', 'analyse', 'generate', 'summarise', 'all', 'recover', 'error')))
754+
stop('debug input is not valid', call. = FALSE)
755755
if(!is.null(design$REPLICATION))
756756
stop("REPLICATION is a reserved keyword in the design object. Please use another name", call.=FALSE)
757757
else design <- data.frame(REPLICATION=integer(nrow(design)), design)
758758
if(is.null(design$ID)){
759759
design <- data.frame(ID=1L:nrow(design), design)
760760
} else stopifnot(length(unique(design$ID)) == nrow(design))
761-
use_try <- !(edit %in% c('error', 'recover'))
762-
if(edit != 'none'){
761+
use_try <- !(debug %in% c('error', 'recover'))
762+
if(debug != 'none'){
763763
save <- save_results <- save_generate_data <- save_seeds <- FALSE
764-
if(!(edit %in% 'summarise')) parallel <- MPI <- FALSE
765-
if(edit == 'error'){
766-
old_recover <- getOption('error')
767-
options(error = browser)
768-
on.exit(options(error = old_recover))
769-
} else if(edit == 'recover'){
770-
old_recover <- getOption('error')
771-
options(error = utils::recover)
772-
on.exit(options(error = old_recover))
773-
} else if(edit == 'all'){
764+
if(!(debug %in% 'summarise')) parallel <- MPI <- FALSE
765+
if(debug == 'all'){
774766
debug(Functions[['generate']]); debug(Functions[['analyse']])
775767
debug(Functions[['summarise']])
776768
on.exit({undebug(Functions[['generate']]); undebug(Functions[['analyse']])
777769
undebug(Functions[['summarise']])})
778770
} else {
779-
debug(Functions[[edit]])
780-
on.exit(undebug(Functions[[edit]]))
771+
debug(Functions[[debug]])
772+
on.exit(undebug(Functions[[debug]]))
781773
}
782774
}
783775
export_funs <- parent_env_fun()

man/runSimulation.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)