Skip to content

Commit

Permalink
foreach no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Apr 24, 2024
1 parent a5a681f commit 1c629d8
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 34 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ VignetteBuilder: knitr
Depends:
R (>= 3.5.0)
Imports:
foreach,
methods,
parallel,
dplyr,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export(rmvt)
export(rtruncate)
export(runArraySimulation)
export(runSimulation)
import(foreach)
import(methods)
import(parallel)
import(stats)
Expand Down
2 changes: 1 addition & 1 deletion R/SimDesign.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' @aliases SimDesign-package
#' @title Structure for Organizing Monte Carlo Simulation Designs
#' @author Phil Chalmers \email{rphilip.chalmers@@gmail.com}
#' @import foreach methods parallel stats
#' @import methods parallel stats
#' @importFrom sessioninfo session_info
#' @importFrom RPushbullet pbPost
#' @importFrom graphics abline
Expand Down
13 changes: 0 additions & 13 deletions R/analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ Analysis <- function(Functions, condition, replications, fixed_objects, cl, MPI,
if(MPI){
stop('MPI structure no longer supported. Please use the parallel = \"future" approach',
call. = FALSE)
# i <- 1L
# results <- try(foreach(i=1L:replications, .export=export_funs, .packages=packages,
# .options.mpi=.options.mpi) %dopar%
# mainsim(i, condition=condition, generate=Functions$generate,
# analyse=Functions$analyse, fixed_objects=fixed_objects, load_seed=load_seed,
# max_errors=max_errors, save=save,
# store_Random.seeds=store_Random.seeds,
# save_seeds=save_seeds, save_seeds_dirname=save_seeds_dirname,
# save_results_out_rootdir=save_results_out_rootdir,
# store_warning_seeds=store_warning_seeds,
# include_replication_index=include_replication_index,
# warnings_as_errors=warnings_as_errors, allow_na=allow_na, allow_nan=allow_nan,
# use_try=use_try, allow_gen_errors=allow_gen_errors), TRUE)
} else {
if(!is.null(seed)) parallel::clusterSetRNGStream(cl=cl, seed[condition$ID])
results <- if(progress){
Expand Down
12 changes: 2 additions & 10 deletions R/runSimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@
#' For Windows OS this defaults to \code{"PSOCK"}, otherwise \code{"SOCK"} is selected
#' (suitable for Linux and Mac OSX). This is ignored if the user specifies their own \code{cl} object}
#'
# \item{\code{MPI}}{logical (default is \code{FALSE}); use the \code{foreach} package in a
# form usable by MPI to run simulation in parallel on a cluster? }
#'
#' \item{\code{print_RAM}}{logical (default is \code{TRUE}); print the amount of RAM
#' used throughout the simulation? Set to \code{FALSE} if unnecessary or if the call to
#' \code{\link{gc}} is unnecessarily time consuming}
Expand All @@ -426,11 +423,6 @@
#' See \code{\link{runArraySimulation}} for the input specifications.
#' }
#'
# \item{\code{.options.mpi}}{list of arguments passed to \code{foreach()} to control the MPI execution
# properties. Only used when \code{MPI = TRUE}}
#'
#'
#'
#' }
#'
#' @param save_details a list pertaining to information regarding how and where files should be saved
Expand Down Expand Up @@ -1342,7 +1334,7 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
parallel::parSapply(cl, 1L:(length(cl)*2),
function(ind, packages) load_packages(packages),
packages=packages)
} # foreach() doesn't like load_packages()
}
} else {
future.apply::future_lapply(1L:(future::nbrOfWorkers()*2),
function(ind, packages) load_packages(packages),
Expand All @@ -1355,7 +1347,7 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
} else if(parallel){
try(table(parallel::parSapply(cl, rep(tmp[i], each=length(cl)*2),
get_packages)))
} else "" # for foreach()
}
if(tmp[i] == 'stats') next
if(length(packs) > 1L)
message(sprintf('Warning message:\nVersions of %s differ across clusters: %s',
Expand Down
4 changes: 0 additions & 4 deletions man/runSimulation.Rd

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

6 changes: 2 additions & 4 deletions vignettes/MultipleAnalyses.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ res <- structure(list(sample_size = c(250, 500, 1000, 250, 500, 1000
"coda", "codetools", "crayon", "curl", "datawizard",
"DBI", "dcurver", "Deriv", "digest", "dplyr", "effectsize",
"ellipsis", "emmeans", "estimability", "evaluate", "fansi",
"foreach", "generics", "glue", "GPArotation", "htmltools",
"generics", "glue", "GPArotation", "htmltools",
"insight", "iterators", "jsonlite", "knitr", "lattice",
"lavaan", "lifecycle", "magrittr", "MASS", "Matrix",
"mgcv", "mirt", "mnormt", "multcomp", "mvtnorm", "nlme",
Expand Down Expand Up @@ -369,7 +369,6 @@ res <- structure(list(sample_size = c(250, 500, 1000, 250, 500, 1000
"C:/R/R-4.0.2/library/dplyr", "C:/R/R-4.0.2/library/effectsize",
"C:/R/R-4.0.2/library/ellipsis", "C:/R/R-4.0.2/library/emmeans",
"C:/R/R-4.0.2/library/estimability", "C:/R/R-4.0.2/library/evaluate",
"C:/R/R-4.0.2/library/fansi", "C:/R/R-4.0.2/library/foreach",
"C:/R/R-4.0.2/library/generics", "C:/R/R-4.0.2/library/glue",
"C:/R/R-4.0.2/library/GPArotation", "C:/R/R-4.0.2/library/htmltools",
"C:/R/R-4.0.2/library/insight", "C:/R/R-4.0.2/library/iterators",
Expand Down Expand Up @@ -406,7 +405,6 @@ res <- structure(list(sample_size = c(250, 500, 1000, 250, 500, 1000
"C:/R/R-4.0.2/library/dplyr", "C:/R/R-4.0.2/library/effectsize",
"C:/R/R-4.0.2/library/ellipsis", "C:/R/R-4.0.2/library/emmeans",
"C:/R/R-4.0.2/library/estimability", "C:/R/R-4.0.2/library/evaluate",
"C:/R/R-4.0.2/library/fansi", "C:/R/R-4.0.2/library/foreach",
"C:/R/R-4.0.2/library/generics", "C:/R/R-4.0.2/library/glue",
"C:/R/R-4.0.2/library/GPArotation", "C:/R/R-4.0.2/library/htmltools",
"C:/R/R-4.0.2/library/insight", "C:/R/R-4.0.2/library/iterators",
Expand Down Expand Up @@ -513,7 +511,7 @@ res <- structure(list(sample_size = c(250, 500, 1000, 250, 500, 1000
"bayestestR", "cli", "cluster", "coda", "codetools", "crayon",
"curl", "datawizard", "DBI", "dcurver", "Deriv", "digest",
"dplyr", "effectsize", "ellipsis", "emmeans", "estimability",
"evaluate", "fansi", "foreach", "generics", "glue", "GPArotation",
"evaluate", "fansi", "generics", "glue", "GPArotation",
"htmltools", "insight", "iterators", "jsonlite", "knitr",
"lattice", "lavaan", "lifecycle", "magrittr", "MASS", "Matrix",
"mgcv", "mirt", "mnormt", "multcomp", "mvtnorm", "nlme",
Expand Down

0 comments on commit 1c629d8

Please sign in to comment.