Skip to content

Commit

Permalink
frame is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Aug 16, 2024
1 parent 63e33ec commit 6644e6a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions R/runArraySimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ runArraySimulation <- function(design, ..., replications,
if(!is.null(control$save_seeds) && isTRUE(control$save_seeds))
stop(c('save_seeds not supported for array jobs. If this is truely',
' necessary use store_Random.seeds instead'))
control$from.runArraySimulation <- TRUE
rngkind <- RNGkind()
RNGkind("L'Ecuyer-CMRG")
on.exit(RNGkind(rngkind[1L]))
Expand Down
3 changes: 2 additions & 1 deletion R/runSimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,8 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
on.exit(undebug(Functions[[debug]]), add = TRUE)
}
}
export_funs <- parent_env_fun()
export_funs <- if(!is.null(control$from.runArraySimulation))
parent_env_fun(3L) else parent_env_fun()
if(parallel){
if(!useFuture && is.null(cl)){
cl <- parallel::makeCluster(ncores, type=type)
Expand Down
8 changes: 4 additions & 4 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.SIMDENV <- new.env(parent=emptyenv())

# return a character vector of functions defined in .GlobalEnv
parent_env_fun <- function(){
nms <- ls(envir = globalenv())
parent_env_fun <- function(level=2){
nms <- ls(envir = parent.frame(level))
is_fun <- sapply(nms, function(x, envir) is.function(get(x, envir=envir)),
envir = globalenv())
envir = parent.frame(level))
return(nms[is_fun])
}

Expand Down Expand Up @@ -942,7 +942,7 @@ valid_control.list <- function()
"store_warning_seeds", "include_replication_index", "include_reps", "try_all_analyse",
"allow_na", "allow_nan", "type", "print_RAM", "max_time", "max_RAM",
"tol", "summarise.reg_data", "rel.tol", "k.success", "interpolate.R", "bolster",
"include_reps")
"include_reps", 'from.runArraySimulation')

valid_save_details.list <- function()
c("safe", "compname", "out_rootdir", "save_results_dirname", "save_results_filename",
Expand Down

0 comments on commit 6644e6a

Please sign in to comment.