Skip to content

Commit

Permalink
Alert users to the name change, re dynamic combine() => group()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Nov 14, 2019
1 parent 078aeaf commit fd6d7ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
23 changes: 16 additions & 7 deletions R/dynamic.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ as_dynamic <- function(x) {
return(x)
}
class(x) <- c(x[[1]], "dynamic", class(x))
match_call(x)
match_dynamic_call(x)
}

dynamic_subvalue <- function(value, index) {
Expand Down Expand Up @@ -417,22 +417,31 @@ dynamic_subvalue_vector <- function(value, index) {
value[index]
}

match_call <- function(dynamic) {
match_dynamic_call <- function(dynamic) {
class <- class(dynamic)
out <- match_call_impl(dynamic)
out <- match_dynamic_call_impl(dynamic)
class(out) <- class
out
}

match_call_impl <- function(dynamic) {
UseMethod("match_call_impl")
match_dynamic_call_impl <- function(dynamic) {
UseMethod("match_dynamic_call_impl")
}

match_call_impl.map <- match_call_impl.cross <- function(dynamic) {
match_dynamic_call_impl.map <- match_dynamic_call_impl.cross <- function(dynamic) {
match.call(definition = def_map, call = dynamic)
}

match_call_impl.group <- function(dynamic) {
match_dynamic_call_impl.combine <- function(dynamic) {
stop(
"Dynamic combine() does not exist. ",
"use group() instead. ",
"Ref: https://github.com/ropensci/drake/issues/1065",
call. = FALSE
)
}

match_dynamic_call_impl.group <- function(dynamic) {
match.call(definition = def_group, call = dynamic)
}

Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-dynamic.R
Original file line number Diff line number Diff line change
Expand Up @@ -1436,3 +1436,12 @@ test_with_dir("dynamic group trace (#1052)", {
expect_equal(get_trace("w_tr", value), LETTERS[seq_len(3)])
expect_equal(read_trace("w_tr", "z"), LETTERS[seq_len(3)])
})


test_with_dir("dynamic combine() does not exist", {
plan <- drake_plan(
x = seq_len(8),
y = target(x, dynamic = combine(x, .by = x))
)
expect_error(make(plan), regexp = "does not exist")
})

1 comment on commit fd6d7ac

@lintr-bot
Copy link

Choose a reason for hiding this comment

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

R/dynamic.R:431:1: style: Lines should not be more than 80 characters.

match_dynamic_call_impl.map <- match_dynamic_call_impl.cross <- function(dynamic) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/dynamic.R:435:1: style: Variable and function names should not be longer than 30 characters.

match_dynamic_call_impl.combine <- function(dynamic) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please sign in to comment.