Skip to content

Commit

Permalink
sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Jul 30, 2024
1 parent 678c29f commit 0959899
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/SimSolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ SimSolve <- function(design, interval, b, generate, analyse, summarise,

# robust <- FALSE
org.opts <- options()
ncores <- check_ncores(ncores)
options(warn = 1)
on.exit(options(org.opts), add = TRUE)
if(is.null(control$print_RAM)) control$print_RAM <- FALSE
Expand Down
1 change: 1 addition & 0 deletions R/runArraySimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ runArraySimulation <- function(design, ..., replications,
save_details = list(),
control = list()){
dots <- list(...)
ncores <- check_ncores(ncores)
if(!is.null(dots$save_results) && isTRUE(dots$save_results))
stop('save_results not supported for array jobs. Please use store_results only')
if(!is.null(control$save_seeds) && isTRUE(control$save_seeds))
Expand Down
1 change: 1 addition & 0 deletions R/runSimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
control = list(), progress = TRUE, verbose = TRUE)
{
stopifnot(!missing(analyse))
ncores <- check_ncores(ncores)
if(length(control)){
stopifnot("Argument(s) to control list invalid"=
all(names(control) %in% valid_control.list()))
Expand Down
6 changes: 6 additions & 0 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ get_packages <- function(packages){
sapply(packages, function(x) as.character(packageVersion(x)))
}

check_ncores <- function(ncores){
ncores <- ifelse(is.na(ncores), 1L, ncores)
ncores <- ifelse(ncores < 1L, 1L, ncores)
ncores
}

# base-code borrowed and modified from pbapply
timeFormater_internal <- function(time, decimals = TRUE){
dec <- time - floor(time)
Expand Down

0 comments on commit 0959899

Please sign in to comment.