-
Notifications
You must be signed in to change notification settings - Fork 105
workshop protected arguments warning #1216
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# warns informatively about protected arguments | ||
|
||
Code | ||
.res <- check_eng_args(args = list(a = 1, b = 2, c = 3, e = 5), obj = obj, | ||
core_args = core_args) | ||
Condition | ||
Warning: | ||
The arguments `a`, `b`, and `c` cannot be manually modified and were removed. | ||
|
||
--- | ||
|
||
Code | ||
.res <- check_eng_args(args = list(b = 2, c = 3, e = 5), obj = obj, core_args = core_args) | ||
Condition | ||
Warning: | ||
The arguments `b` and `c` cannot be manually modified and were removed. | ||
|
||
--- | ||
|
||
Code | ||
.res <- check_eng_args(args = list(c = 3, e = 5), obj = obj, core_args = core_args) | ||
Condition | ||
Warning: | ||
The argument `c` cannot be manually modified and was removed. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,25 +32,6 @@ | |
x Engine "wat?" is not supported for `mlp()` | ||
i See `show_engines("mlp")`. | ||
|
||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each of these removed snapshots both tested duplicates of the print method and this warning message. |
||
|
||
Code | ||
translate(mlp(mode = "regression") %>% set_engine("nnet", formula = y ~ x)) | ||
Condition | ||
Warning: | ||
The argument `formula` cannot be manually modified and was removed. | ||
Output | ||
Single Layer Neural Network Model Specification (regression) | ||
Main Arguments: | ||
hidden_units = 5 | ||
Computational engine: nnet | ||
Model fit template: | ||
nnet::nnet(formula = missing_arg(), data = missing_arg(), size = 5, | ||
trace = FALSE, linout = TRUE) | ||
|
||
# check_args() works | ||
|
||
Code | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this is a totally new test file. This warning is tested in a couple engine-specific files already—I just test for the subclass now. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
test_that("warns informatively about protected arguments", { | ||
obj <- list(protect = c("a", "b")) | ||
core_args <- c("c", "d") | ||
|
||
expect_snapshot( | ||
.res <- check_eng_args( | ||
args = list(a = 1, b = 2, c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
) | ||
) | ||
|
||
expect_snapshot( | ||
.res <- check_eng_args( | ||
args = list(b = 2, c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
) | ||
) | ||
|
||
expect_snapshot( | ||
.res <- check_eng_args( | ||
args = list(c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
) | ||
) | ||
|
||
expect_warning( | ||
check_eng_args( | ||
args = list(a = 1, b = 2, c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
), | ||
class = "parsnip_protected_arg_warning" | ||
) | ||
}) |
Uh oh!
There was an error while loading. Please reload this page.