-
Notifications
You must be signed in to change notification settings - Fork 255
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
Make modify_depth() and map_depth() consistent with modify_tree() #960
Conversation
@@ -8,7 +8,8 @@ | |||
#' @param leaf A function applied to each leaf. | |||
#' @param is_leaf A predicate function that determines whether an element is | |||
#' a leaf (by returning `FALSE`) or a node (by returning `FALSE`). The | |||
#' default value, `NULL`, treats lists as nodes and everything else as leaves. | |||
#' default value, `NULL`, treats bare lists as nodes and everything else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to vec_is_list()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave this as is since once I switch to is_node
instead of is_leaf
the default will become vec_is_list()
and then it's obvious.
|
||
x <- list(data.frame(x = 1), data.frame(y = 1)) | ||
expect_equal( | ||
map_depth(x, 2, class, .is_leaf = Negate(is.list)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of Negate
makes me wonder if it wouldn't be better to take is_node
instead of is_leaf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wondered about this too. I might do it in a separate PR.
Co-authored-by: Lionel Henry <lionel.hry@gmail.com>
Create new vctrs compatibility helper, and use it in a few places. "Weird" vectors like pairlists, expressions, and calls have been deprecated.
Fixes #958