Skip to content

Commit

Permalink
fixed note regarding multicore
Browse files Browse the repository at this point in the history
Resubmitted to CRAN
  • Loading branch information
richarddmorey committed Aug 29, 2014
1 parent 6828da9 commit 51cf9cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/BayesFactor/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ License: GPL-2
VignetteBuilder: knitr
Depends: R (>= 3.0.0), coda, methods
Imports: pbapply, mvtnorm, stringr, utils, graphics
Suggests: doMC, testthat, knitr, markdown, arm, lme4, xtable, languageR
Suggests: doMC, foreach, testthat, knitr, markdown, arm, lme4, xtable, languageR
URL: http://bayesfactorpcl.r-forge.r-project.org/
BugReports: https://github.com/richarddmorey/BayesFactor/issues
LazyLoad: yes
12 changes: 7 additions & 5 deletions pkg/BayesFactor/R/anovaBF.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,22 @@ anovaBF <-
}

if(multicore){
warning("Progress bars and callbacks are suppressed when running multicore.")
if(!require(doMC)){
message("Progress bars and callbacks are suppressed when running multicore.")
if(!require(doMC, quietly = TRUE)){
stop("Required package (doMC) missing for multicore functionality.")
}

registerDoMC()
if(getDoParWorkers()==1){
doMC::registerDoMC()
if(foreach::getDoParWorkers()==1){
warning("Multicore specified, but only using 1 core. Set options(cores) to something >1.")
}

bfs <- foreach(gIndex=models, .options.multicore=mcoptions) %dopar%
bfs <- foreach::"%dopar%"(
foreach::foreach(gIndex=models, .options.multicore=mcoptions),
lmBF(gIndex,data = data, whichRandom = whichRandom,
rscaleFixed = rscaleFixed, rscaleRandom = rscaleRandom,
iterations = iterations, method=method,progress=FALSE,noSample=noSample)
)

}else{ # Single core

Expand Down
13 changes: 7 additions & 6 deletions pkg/BayesFactor/R/generalTestBF.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,23 @@ generalTestBF <-
"options('BFMaxModels').")

if(multicore){
warning("Progress bars and callbacks are suppressed when running multicore.")
if(!require(doMC)){
message("Progress bars and callbacks are suppressed when running multicore.")
if(!require(doMC, quietly = TRUE)){
stop("Required package (doMC) missing for multicore functionality.")
}

registerDoMC()
if(getDoParWorkers()==1){
doMC::registerDoMC()
if(foreach::getDoParWorkers()==1){
warning("Multicore specified, but only using 1 core. Set options(cores) to something >1.")
}

bfs <- foreach(gIndex=models, .options.multicore=mcoptions) %dopar%
bfs <- foreach::"%dopar%"(
foreach::foreach(gIndex=models, .options.multicore=mcoptions),
lmBF(gIndex,data = data, whichRandom = whichRandom,
rscaleFixed = rscaleFixed, rscaleRandom = rscaleRandom,
rscaleCont = rscaleCont, iterations = iterations, method=method,
progress=FALSE,noSample=noSample)

)
}else{ # Single core

bfs = NULL
Expand Down

0 comments on commit 51cf9cc

Please sign in to comment.