tests/testthat/test_parallelApply.R

context("parallel apply")

test_that("parallelLapply", {
  parallelStart(mode = "local")

  ys = parallelLapply(1:2, identity)
  expect_equal(ys, as.list(1:2))

  xs = list(a = 1, b = 2)
  ys = parallelLapply(xs, identity)
  expect_equal(ys, xs)

  parallelStop()
})


test_that("parallelSapply", {

  parallelStart(mode = "local")

  xs = c("a", "b")
  ys = parallelSapply(xs, identity, use.names = FALSE)
  expect_equal(ys, xs)
  ys = parallelSapply(xs, identity, use.names = TRUE)
  expect_equal(ys, setNames(xs, xs))

  expect_equal(
    parallelSapply(1:2, identity),
    sapply(1:2, identity)
  )

  parallelStop()
})

Try the parallelMap package in your browser

Any scripts or data that you put into this service are public.

parallelMap documentation built on June 28, 2021, 9:07 a.m.