tests/testthat/test-feature-ign-singletons.R

context("Feature Ignore Singletons")

test_that("we can add remove singletons to a models", {
  model <- coal_model(10, 1) + feat_ignore_singletons()
  expect_true(has_ign_singletons(model))
  expect_false(has_ign_singletons(coal_model(10, 1)))
})


test_that("the function to remove singletons works", {
  ssl <- list(create_test_segsites(), create_test_segsites())
  expect_equal(remove_singletons(ssl),
               list(create_test_segsites()[, -c(1, 3)],
                    create_test_segsites()[, -c(1, 3)]))

  expect_equal(remove_singletons(list(create_empty_segsites())),
               list(create_empty_segsites()))
})


test_that("singletons are removed from simulations", {
  model <- coal_model(2, 1) +
    feat_mutation(10) +
    feat_ignore_singletons() +
    sumstat_sfs()
  expect_equal(simulate(model)$sfs, 0)
})

Try the coala package in your browser

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

coala documentation built on Jan. 5, 2023, 5:11 p.m.