Skip to content
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

add ignore_step function #1324

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

add ignore_step function #1324

wants to merge 2 commits into from

Conversation

EmilHvitfeldt
Copy link
Member

to close #887

Adds ignore_step(), with a similar interface as tidy() with respect to how we select, either using number or id.

I'm not in love with the name, so suggestions are welcome.

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.

I would not use "ignore" in the name here because that implies the step(s) in question are still part of the recipe, they just don't get used -- but this does remove them. I think remove_step() would be the cleanest but if we want to avoid "remove" because of step_rm(), we could go with "undo" or "delete".

Comment on lines +40 to +44
if (n_steps == 0) {
cli::cli_abort("{.arg x} doesn't contain any steps to remove.")
}

arg <- rlang::check_exclusive(number, id)
Copy link
Member

Choose a reason for hiding this comment

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

We could allow ignore_step(<recipes without steps>) and just have it do nothing. If we don't want that, I would swap these two checks. To me, it's more obvious then that we don't allow that because we always require you to provide what to remove (before we tell you that there is nothing to remove).

#'
#' ignore_step(rec, id = "PCA")
#' @export
ignore_step <- function(x, number, id) {
Copy link
Member

Choose a reason for hiding this comment

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

I would give number and id some default values since only one of the two is required. tidy() uses NA.

Comment on lines +24 to +28
expect_equal(
ignore_attr = TRUE,
ignore_step(rec1234, number = 1),
rec234
)
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised by the argument order here, why do you put ignore_attr up front?

#' `ignore_step` will return a recipe without steps specified by the `number` or
#' `id` argument.
#'
#' @param x A `recipe` object.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#' @param x A `recipe` object.
#' @param x An untrained `recipe` object.

Comment on lines +7 to +10
#' @param number An integer vector, Denoting the positions of the steps that
#' should be removed.
#' @param id A character string. Denoting the `id` of the steps that should be
#' removed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#' @param number An integer vector, Denoting the positions of the steps that
#' should be removed.
#' @param id A character string. Denoting the `id` of the steps that should be
#' removed.
#' @param number An integer vector denoting the positions of the steps that
#' should be removed.
#' @param id A character string denoting the `id` of the steps that should be
#' removed.

@EmilHvitfeldt
Copy link
Member Author

We are sitting on this for another week. Brief summary of meeting discussion:

  • There is some doubt that this could lead to problems down the line AND/OR subtle bugs
  • feels like syntactic sugar
  • Isn't a bad idea, but maybe better suited for an extension package
  • can be imagined as part of a broader group of functions that modify recipes
    • swap steps, move steps up and down

@EmilHvitfeldt
Copy link
Member Author

we are sitting on this at least another week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function that removes step(s) from an existing recipe
2 participants