tests/testthat/test-parallel.R

test_that("Parallelization works", {
  library("TreeTools")
  trees <- as.phylo(0:20, 20)
  
  suppressMessages({
  expect_equal(options("TreeDist-cluster"), StartParallel(2))
  cl <- getOption("TreeDist-cluster")
  
  parallel <- ClusteringInfoDistance(trees)
  SetParallel(NULL)
  expect_null(GetParallel())
  expect_equal(ClusteringInfoDistance(trees), parallel)

  expect_equal(options("TreeDist-cluster"), SetParallel(cl))
  expect_equal(cl, getOption("TreeDist-cluster"))
  expect_equal(cl, GetParallel())
  parallel <- CompareAll(trees, NNIDist)
  SetParallel(NULL)
  expect_equal(CompareAll(trees, NNIDist), parallel)
  expect_false(StopParallel())
  SetParallel(cl)
  expect_true(StopParallel())
    })
})

Try the TreeDist package in your browser

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

TreeDist documentation built on Oct. 26, 2023, 1:07 a.m.