tests/testthat/test-core.R

testthat::test_that("internal preprocessing is fitted and reusable", {
  preprocess <- getFromNamespace(".sense_preprocess", "sense")
  bake <- getFromNamespace(".sense_bake", "sense")
  config <- list(impute_num = "sample", num_preproc = "scale",
    fct_preproc = "one-hot", collapse_char_to = 3L,
    missing_fusion = TRUE, selected_filter = "variance", selected_n_feats = 10L)
  train <- data.frame(number = c(NA, 2:8), category = c("a", "a", "b", "b", "c", "c", "d", "d"))
  state <- preprocess(train, seq_len(nrow(train)), config)
  prediction <- bake(state, data.frame(number = c(100, NA), category = c("unseen", "a")))
  testthat::expect_equal(names(prediction), names(state$data))
  testthat::expect_true(all(is.finite(as.matrix(prediction))))
  testthat::expect_gt(prediction[["x1_1"]][1L], 10)
})

testthat::test_that("internal stack has no mlr3pipelines dependency", {
  description <- packageDescription("sense")
  imports <- if (is.null(description[["Imports"]])) "" else description[["Imports"]]
  testthat::expect_false(grepl("mlr3pipelines", imports, fixed = TRUE))
  testthat::expect_true(is.function(getS3method("plot", "sense_pipeline")))
})

Try the sense package in your browser

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

sense documentation built on Sept. 8, 2026, 9:08 a.m.