tests/testthat/test-ckdat-validation.R

test_that("public APIs reject non-numeric matrix data before entering C", {
  bad <- matrix(letters[1:4], ncol = 2)
  params <- list(
    proportion = 1,
    mean = matrix(c(0, 0), ncol = 1),
    cov = array(diag(2), dim = c(2, 2, 1))
  )
  good_method <- function(data) {
    list(params = clust2params(data, rep(1L, nrow(data))))
  }

  expect_error(
    gmix(bad, K = 2),
    "matrix/array must be numeric"
  )
  expect_error(
    qscore(bad, params),
    "matrix/array must be numeric"
  )
  expect_error(
    clust2params(bad, c(1L, 1L)),
    "matrix/array must be numeric"
  )
  expect_error(
    bqs(bad, good_method, B = 0, ncores = 1, rankby = "mean"),
    "matrix/array must be numeric"
  )
})

Try the qcluster package in your browser

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

qcluster documentation built on June 5, 2026, 5:07 p.m.