tests/testthat/test-variance_threshold.R

context("variance_threshold")

test_that(
  "`variance_threshold` selects variables that have non-trivial variance",
  {
    data <- data.frame(x = rnorm(30), y = 1)

    db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")

    data <- dplyr::copy_to(db, data)

    expect_equal(
      variance_threshold(
        variables = c("x", "y"),
        sample = data %>% dplyr::collect()
      ),
      c("y")
    )

    expect_equal(
      variance_threshold(
        variables = c("x"),
        sample = data %>% dplyr::collect()
      ),
      character(0)
    )

    DBI::dbDisconnect(db)
  }
)

Try the cytominer package in your browser

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

cytominer documentation built on July 8, 2020, 5:08 p.m.