Skip to content

don't pick up tune() from parsnip objects in tune_args() #1507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# recipes (development version)

* Fixed bug where `tune_args()` would error if argument to step had a parsnip object with tuned arguments. ($1506)

# recipes 1.3.0

* Fixed printing for `step_geodist()` when no variables are selected. (#1423)
Expand Down
3 changes: 3 additions & 0 deletions R/tune_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ find_tune_id <- function(x) {
if (length(x) == 0L) {
return(NA_character_)
}
if (is.list(x) && !inherits(x, "list")) {
return(NA_character_)
}

# turn quosures into expressions before continuing
if (rlang::is_quosures(x)) {
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-tune_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,21 @@ test_that("tune_args() doesn't error on namespaced selectors", {
exp
)
})

test_that("tune_args() wont detect tune() calls in parsnip objects (#1506)", {
skip_if_not_installed("parsnip")
skip_if_not_installed("rpart")

base_model <- parsnip::decision_tree(cost_complexity = hardhat::tune())

rec_empty <- recipe(mpg ~ ., data = mtcars) |>
step_testthat_helper(output = base_model)

rec_mod <- recipe(mpg ~ ., data = mtcars) |>
step_testthat_helper()

expect_identical(
extract_parameter_set_dials(rec_empty),
extract_parameter_set_dials(rec_mod)
)
})