/usr/lib/R/site-library/BiocParallel/unitTests/test_bplapply.R is in r-bioc-biocparallel 1.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | library(doParallel)
quiet <- suppressWarnings
test_bplapply_Params <- function()
{
registerDoParallel(2)
params <- list(serial=SerialParam(),
snow=SnowParam(2),
dopar=DoparParam(),
batchjobs=BatchJobsParam())
if (.Platform$OS.type != "windows")
params$mc <- MulticoreParam(2)
x <- 1:10
expected <- lapply(x, sqrt)
for (param in names(params)) {
current <- quiet(bplapply(x, sqrt, BPPARAM=params[[param]]))
checkIdentical(expected, current)
}
# test empty input
for (param in names(params)) {
current <- quiet(bplapply(list(), identity, BPPARAM=params[[param]]))
checkIdentical(list(), current)
}
# unnamed args for BatchJobs -> dispatches to batchMap
f <- function(i, x, y, ...) { list(y, i, x) }
current <- bplapply(2:1, f, c("A", "B"), x=10, BPPARAM=BatchJobsParam())
checkTrue(all.equal(current[[1]], list(c("A", "B"), 2, 10)))
checkTrue(all.equal(current[[2]], list(c("A", "B"), 1, 10)))
## clean up
env <- foreach:::.foreachGlobals
rm(list=ls(name=env), pos=env)
closeAllConnections()
TRUE
}
test_bplapply_symbols <- function()
{
registerDoParallel(2)
params <- list(serial=SerialParam(),
snow=SnowParam(2),
dopar=DoparParam())
# batchjobs=BatchJobsParam()) ## FIXME
if (.Platform$OS.type != "windows")
params$mc <- MulticoreParam(2)
x <- list(as.symbol(".XYZ"))
expected <- lapply(x, as.character)
for (param in names(params)) {
current <- quiet(bplapply(x, as.character, BPPARAM=params[[param]]))
checkIdentical(expected, current)
}
## clean up
env <- foreach:::.foreachGlobals
rm(list=ls(name=env), pos=env)
closeAllConnections()
TRUE
}
|