Skip to content

document that main arguments are captured as quosures #918

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 4 commits into from
Mar 10, 2023
Merged

Conversation

simonpcouch
Copy link
Contributor

Closes #662.🦀

If we think the model_type() pseudocode may be confusing for folks, we could make this into a proper template that could take the name of the model type function as an input. :)

@simonpcouch simonpcouch requested a review from hfrick March 9, 2023 20:19
Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think we should change something about that model_type() snippet. It using the actual modelling function would be nice. A possibly easier solution is to explicitly say that this is pseudo-code. Either solution is fine with me.

@@ -6,3 +6,12 @@
#'
#' The model is not trained or fit until the [`fit()`][fit.model_spec()] function is used
#' with the data.
#'
#' Each of the arguments defaulting to `NULL` in this function are captured
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pattern is "every arg apart from mode and engine" but I haven't checked all of them. I did hit bag_tree() though which has non-NULL defaults for some main args and all of them get captured as quosures:

parsnip/R/bag_tree.R

Lines 25 to 37 in 332de18

bag_tree <-
function(mode = "unknown",
cost_complexity = 0,
tree_depth = NULL,
min_n = 2,
class_cost = NULL,
engine = "rpart") {
args <- list(
cost_complexity = enquo(cost_complexity),
tree_depth = enquo(tree_depth),
min_n = enquo(min_n),
class_cost = enquo(class_cost)
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. Thank you!

@simonpcouch
Copy link
Contributor Author

I'm with ya. Let's make this into a proper template and substitute the function name in.

@simonpcouch simonpcouch requested a review from hfrick March 10, 2023 14:44
Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's so neat! I didn't know about that 👀 🤩

@simonpcouch simonpcouch merged commit 3725810 into main Mar 10, 2023
@simonpcouch simonpcouch deleted the quosures-662 branch March 10, 2023 16:20
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to pass NULL to boost_tree model
2 participants