tests/testthat/test-control.R

# Input-validation coverage for DSA.control().

test_that("DSA.control returns sane defaults", {
  ctrl <- DSA.control()
  expect_equal(ctrl$vfold, 10)
  expect_equal(ctrl$minsplit, 20)
  expect_equal(ctrl$minbuck, round(20 / 3))
  expect_equal(ctrl$cut.off.growth, 10)
  expect_equal(ctrl$loss.function, "default")
  expect_equal(ctrl$leafy, 0)
  expect_equal(ctrl$boost, 0)
})

test_that("DSA.control rejects invalid numeric arguments", {
  expect_error(DSA.control(vfold = 0), "vfold")
  expect_error(DSA.control(vfold = c(2, 3)), "vfold")
  expect_error(DSA.control(minsplit = 0), "minsplit")
  expect_error(DSA.control(minbuck = -1), "minbuck")
  expect_error(DSA.control(cut.off.growth = 0), "cut.off.growth")
  expect_error(DSA.control(MPD = -0.1), "MPD")
})

test_that("DSA.control validates leafy, boosting and subsample arguments", {
  expect_error(DSA.control(leafy = 1, leafy.num.trees = 2.5), "whole number")
  expect_error(DSA.control(leafy = 1, leafy.num.trees = 0), "greater than 0")
  expect_error(DSA.control(leafy = 1, leafy.random.num.variables.per.split = 0),
               "greater than 0")
  expect_error(DSA.control(boost = 1, cut.off.growth = 6), "not greater than 5")
  expect_error(DSA.control(leafy.subsample = 1.5), "leafy.subsample")
  expect_error(DSA.control(leafy.subsample = -0.1), "leafy.subsample")
})

test_that("DSA.control validates type arguments", {
  expect_error(DSA.control(save.input = "yes"), "save.input")
  expect_error(DSA.control(partial = "quartiles"), "deciles")
  expect_error(DSA.control(brier.vec = "a"), "brier.vec")
})

Try the partDSA package in your browser

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

partDSA documentation built on July 8, 2026, 9:06 a.m.