From a04edb5ec87d06adb0c1718e14565fa3206e1ecb Mon Sep 17 00:00:00 2001 From: topepo Date: Thu, 30 Oct 2025 09:41:43 -0400 Subject: [PATCH] changes for #409 --- NEWS.md | 2 ++ R/space_filling.R | 2 +- tests/testthat/test-space_filling.R | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 9fc84a3f..c1384934 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # dials (development version) +* A bug was fixed where some space-filling designs did not respect the `original` argument (#409). + # dials 1.4.2 * `prop_terms()` is a new parameter object used for recipes that do supervised feature selection (#395). diff --git a/R/space_filling.R b/R/space_filling.R index 87f0f7c2..f1d5ed81 100644 --- a/R/space_filling.R +++ b/R/space_filling.R @@ -224,7 +224,7 @@ make_sfd <- function( if (has_premade_design) { grid <- sfd::get_design(p, num_points = size, type = type) - vals <- purrr::map(params, \(.x) value_seq(.x, size)) + vals <- purrr::map(params, \(.x) value_seq(.x, size, original = original)) vals <- purrr::map(vals, \(.x) base_recycle(.x, size)) grid <- sfd::update_values(grid, vals) names(grid) <- names(params) diff --git a/tests/testthat/test-space_filling.R b/tests/testthat/test-space_filling.R index 2123cb08..d0ec9ed6 100644 --- a/tests/testthat/test-space_filling.R +++ b/tests/testthat/test-space_filling.R @@ -330,3 +330,25 @@ test_that("1-point grid", { }) expect_equal(nrow(grid), 1L) }) + +test_that("pre-made designs respect the 'original argument", { + # See issue #409 + + prms <- parameters(penalty(), mixture()) + types <- c( + "audze_eglais", + "max_min_l1", + "max_min_l2", + "uniform", + "max_entropy", + "latin_hypercube" + ) + + for (i in types) { + grd_orig <- grid_space_filling(prms, type = i, original = TRUE) + grd_trans <- grid_space_filling(prms, type = i, original = FALSE) + + expect_true(all(grd_orig$penalty > 0)) + expect_true(all(grd_trans$penalty <= 0)) + } +})