Skip to content

Commit

Permalink
BUG FIX: Make sure %dorng% works also when 'foreach' is not attached (f…
Browse files Browse the repository at this point in the history
…ix #18)

Secured also two other do.call() instances that called a function by string rather than by function object
  • Loading branch information
HenrikBengtsson committed Nov 24, 2020
1 parent 2f985ed commit 0bb3a85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/doRNG.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ getDoBackend <- function(){
}
setDoBackend <- function(backend){
ob <- getDoBackend()
do.call('setDoPar', backend)
do.call(setDoPar, backend)
invisible(ob)
}

Expand Down Expand Up @@ -371,7 +371,7 @@ setDoBackend <- function(backend){
# generate a sequence of streams
# print("before RNGseq")
# showRNG()
obj$args$.doRNG.stream <- do.call("doRNGseq", c(list(n=N_elem, verbose=obj$verbose), rngSeed))
obj$args$.doRNG.stream <- do.call(doRNGseq, c(list(n=N_elem, verbose=obj$verbose), rngSeed))
# print("after RNGseq")
# showRNG()
#print(obj$args$.doRNG.stream)
Expand Down Expand Up @@ -429,7 +429,7 @@ setDoBackend <- function(backend){
substitute(ex)))

# call the standard %dopar% operator
res <- do.call('%dopar%', list(obj, ex), envir=parent.frame())
res <- do.call(`%dopar%`, list(obj, ex), envir=parent.frame())
# add seed sequence as an attribute (skip this for NULL results)
if( !is.null(res) ){
attr(res, 'rng') <- obj$args$.doRNG.stream
Expand Down

0 comments on commit 0bb3a85

Please sign in to comment.