Skip to content

Commit 8dc612a

Browse files
authored
Merge pull request #410 from tidymodels/sfd-original-arg
SFDs should respect the 'original' argument
2 parents 4f94fb7 + a04edb5 commit 8dc612a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# dials (development version)
22

3+
* A bug was fixed where some space-filling designs did not respect the `original` argument (#409).
4+
35
# dials 1.4.2
46

57
* `prop_terms()` is a new parameter object used for recipes that do supervised feature selection (#395).

R/space_filling.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ make_sfd <- function(
224224

225225
if (has_premade_design) {
226226
grid <- sfd::get_design(p, num_points = size, type = type)
227-
vals <- purrr::map(params, \(.x) value_seq(.x, size))
227+
vals <- purrr::map(params, \(.x) value_seq(.x, size, original = original))
228228
vals <- purrr::map(vals, \(.x) base_recycle(.x, size))
229229
grid <- sfd::update_values(grid, vals)
230230
names(grid) <- names(params)

tests/testthat/test-space_filling.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,25 @@ test_that("1-point grid", {
330330
})
331331
expect_equal(nrow(grid), 1L)
332332
})
333+
334+
test_that("pre-made designs respect the 'original argument", {
335+
# See issue #409
336+
337+
prms <- parameters(penalty(), mixture())
338+
types <- c(
339+
"audze_eglais",
340+
"max_min_l1",
341+
"max_min_l2",
342+
"uniform",
343+
"max_entropy",
344+
"latin_hypercube"
345+
)
346+
347+
for (i in types) {
348+
grd_orig <- grid_space_filling(prms, type = i, original = TRUE)
349+
grd_trans <- grid_space_filling(prms, type = i, original = FALSE)
350+
351+
expect_true(all(grd_orig$penalty > 0))
352+
expect_true(all(grd_trans$penalty <= 0))
353+
}
354+
})

0 commit comments

Comments
 (0)