tests/testthat/test-window.R

pacman::p_load("testthat","popgen.stats")

context("sub_window function")

test_that("Windows split properly",{
  set.seed(1939)
  seq=matrix(sample(0:1, size = 24, replace = TRUE), nc = 8)
  win=sub_window(seq,4)
  win1=matrix(c(0,1,0,1,1,1,0,0,0,1,0,0),ncol=4)
  win2=matrix(c(0,1,0,0,0,1,1,1,1,0,0,0),ncol=4)
  expect_equal(all.equal(win[[1]],win1),T)
  expect_equal(all.equal(win[[2]],win2),T)

  set.seed(1940)
  seq=matrix(sample(0:1, size = 40, replace = TRUE), nc = 8)
  win=sub_window(seq,3)
  win1=matrix(c(1,1,1,1,0,1,1,1,1,1,0,0,1,1,1),ncol=3)
  win2=matrix(c(1,0,0,1,0,0,1,1,1,1,1,0,0,0,1),ncol=3)
  win3=matrix(c(1,0,1,1,1,0,0,0,0,1),ncol=2)

  expect_equal(all.equal(win[[1]],win1),T)
  expect_equal(all.equal(win[[2]],win2),T)
  expect_equal(all.equal(win[[3]],win3),T)

})
deponent-verb/popgen.stats documentation built on Nov. 4, 2019, 10:26 a.m.