tests/testthat/test_imputeMissingData.R

testthat::context("Testing the imputation of missing values")

testthat::test_that("No NAs, serial", {
  bpparam <- SerialParam(log = TRUE, threshold = "INFO")
  data <- as.matrix(Hilbert(50))


  res <- imputeMissingData(
    data = data, BPPARAM = bpparam,
    rowBlockSize = 10, colBlockSize = 10,
    fixedSeed = TRUE, outputFormat = ""
  )
  colnames(res) <- NULL
  testthat::expect_equal(res, data)
})

testthat::test_that("NAs, serial", {
  bpparam <- SerialParam(log = TRUE, threshold = "INFO")
  data <- as.matrix(Hilbert(10))

  data_missing <- data
  data_missing[1, 3] <- NA
  data_missing[9, 5] <- NA

  res <- imputeMissingData(
    data = data_missing, BPPARAM = bpparam,
    rowBlockSize = 0, colBlockSize = 0,
    fixedSeed = TRUE, outputFormat = ""
  )
  colnames(res) <- NULL
  data[1, 3] <- 0.116
  data[9, 5] <- 0.020
  testthat::expect_equal(res, data, tolerance = .01)
})

Try the BEclear package in your browser

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

BEclear documentation built on Nov. 8, 2020, 8:07 p.m.