Skip to content

Commit d879482

Browse files
EmilHvitfeldtDavisVaughantopepo
authored
use rlang::is_call_simple (#746)
* use rlang::is_call_simple * add test * update news * Update NEWS.md Co-authored-by: Davis Vaughan <[email protected]> Co-authored-by: Davis Vaughan <[email protected]> Co-authored-by: Max Kuhn <[email protected]>
1 parent 1e8e215 commit d879482

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
* Model type functions will now message informatively if a needed parsnip extension package is not loaded (#731).
2525

26+
* Fixed a bug where an error would be thrown if arguments to model functions were namespaced (#745).
27+
2628
* Refactored internals of model specification printing functions. These changes are non-breaking for extension packages, but the new `print_model_spec()` helper is exported for use in extensions if desired (#739).
2729

2830

R/tune_args.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ tune_id <- function(x) {
102102

103103
# [tune()] will always return a call object
104104
if (is.call(x)) {
105-
if (rlang::call_name(x) == "tune") {
105+
if (rlang::is_call_simple(x) && rlang::call_name(x) == "tune") {
106106
# If an id was specified:
107107
if (length(x) > 1) {
108108
return(x[[2]])

tests/testthat/test_extract.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,17 @@ test_that('extract single parameter from model with main and engine parameters',
8080
NA
8181
)
8282
})
83+
84+
test_that("extract_parameter_dials doesn't error if namespaced args are used", {
85+
skip_on_covr()
86+
skip_if(tune_check())
87+
88+
bst_model <-
89+
logistic_reg(mode = "classification", penalty = hardhat::tune()) %>%
90+
set_engine("glmnet", family = stats::gaussian("log"))
91+
92+
expect_error(
93+
extract_parameter_dials(bst_model, parameter = "penalty"),
94+
NA
95+
)
96+
})

0 commit comments

Comments
 (0)