From c8a448ca80925772769b02569c2a7809d5953c9e Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 18 Jan 2024 11:54:34 +0100 Subject: [PATCH 01/19] test for ; case --- tests/testthat/test-get_code.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test-get_code.R b/tests/testthat/test-get_code.R index 32054ba58..09360c3b8 100644 --- a/tests/testthat/test-get_code.R +++ b/tests/testthat/test-get_code.R @@ -166,6 +166,17 @@ testthat::test_that("get_code returns result of length 1 for non-empty input", { testthat::expect_length(get_code(tdata1, deparse = TRUE), 1) }) +testthat::test_that("get_code does not break if code is separated by ;", { + code <- c( + "a <- 1;a <- a + 1" + ) + tdata <- eval_code(teal_data(), code) + testthat::expect_identical( + get_code(tdata, datanames = "a"), + gsub(";", "\n", code, fixed = TRUE) + ) +}) + # assign ---------------------------------------------------------------------------------------------------------- From 5cdb5f7b924fc1639a42648becc976fe589421c0 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 30 Jul 2024 09:44:43 +0200 Subject: [PATCH 02/19] WIP - topological sort for datanames --- R/join_keys.R | 1 + R/teal_data-class.R | 2 ++ R/teal_data-datanames.R | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/R/join_keys.R b/R/join_keys.R index 47fb97836..5a1265233 100644 --- a/R/join_keys.R +++ b/R/join_keys.R @@ -142,6 +142,7 @@ join_keys.teal_data <- function(...) { #' join_keys(td) `join_keys<-.teal_data` <- function(x, value) { join_keys(x@join_keys) <- value + x@datanames <- sort_datanames(x@datanames, x@join_keys) x } diff --git a/R/teal_data-class.R b/R/teal_data-class.R index 542ee76bb..eca5307b6 100644 --- a/R/teal_data-class.R +++ b/R/teal_data-class.R @@ -82,6 +82,8 @@ new_teal_data <- function(data, new_env <- rlang::env_clone(list2env(data), parent = parent.env(.GlobalEnv)) lockEnvironment(new_env, bindings = TRUE) + datanames <- sort_datanames(datanames, join_keys) + methods::new( "teal_data", env = new_env, diff --git a/R/teal_data-datanames.R b/R/teal_data-datanames.R index 929f09eb1..83fe47ddf 100644 --- a/R/teal_data-datanames.R +++ b/R/teal_data-datanames.R @@ -43,6 +43,7 @@ setGeneric("datanames<-", function(x, value) standardGeneric("datanames<-")) setMethod("datanames<-", signature = c("teal_data", "character"), definition = function(x, value) { checkmate::assert_subset(value, names(x@env)) x@datanames <- value + x@datanames <- sort_datanames(x@datanames, x@join_keys) methods::validObject(x) x }) @@ -50,3 +51,17 @@ setMethod("datanames<-", signature = c("qenv.error", "character"), definition = methods::validObject(x) x }) + + +#' @keywords internal +sort_datanames <- function(datanames, joinkeys) { + + child_parent <- sapply( + datanames, + function(name) teal.data::parent(joinkeys, name), + USE.NAMES = TRUE, + simplify = FALSE + ) + + intersect(topological_sort(child_parent), datanames) +} From 621cfb56e4749e7c5780c53c76b474381c789c47 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:56:51 +0200 Subject: [PATCH 03/19] Update R/teal_data-datanames.R Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/teal_data-datanames.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/teal_data-datanames.R b/R/teal_data-datanames.R index 83fe47ddf..613bba482 100644 --- a/R/teal_data-datanames.R +++ b/R/teal_data-datanames.R @@ -63,5 +63,5 @@ sort_datanames <- function(datanames, joinkeys) { simplify = FALSE ) - intersect(topological_sort(child_parent), datanames) + union(unlist(topological_sort(child_parent)), datanames) } From 96228a08a93a79b4c2398d01e1a08e2955fbc82a Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 31 Jul 2024 11:17:29 +0200 Subject: [PATCH 04/19] add two tests for topological_sort --- tests/testthat/test-datanames.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/testthat/test-datanames.R b/tests/testthat/test-datanames.R index 68966006f..9d5f982db 100644 --- a/tests/testthat/test-datanames.R +++ b/tests/testthat/test-datanames.R @@ -41,3 +41,34 @@ testthat::test_that("datanames<- called on qenv.error does not change qenv.error qec <- qe testthat::expect_identical(qe, qec) }) + +# topological_order ---- +testthat::test_that("datanames return topological order of datasets once join_keys are specified", { + data <- within(teal_data(), { + ADTTE <- teal.data::rADTTE + iris <- iris + ADSL <- teal.data::rADSL + }) + datanames(data) <- c("ADTTE", "iris", "ADSL") + join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] + testthat::expect_identical( + datanames(data), + c("ADSL", "ADTTE", "iris") + ) +}) + +testthat::test_that("datanames return topological order of datasets after datanames are caled after join_keys", { + data <- within(teal_data(), { + ADTTE <- teal.data::rADTTE + iris <- iris + ADSL <- teal.data::rADSL + }) + + join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] + datanames(data) <- c("ADTTE", "iris", "ADSL") + + testthat::expect_identical( + datanames(data), + c("ADSL", "ADTTE", "iris") + ) +}) From 784965ba5d7400a38f4cb5025e5dcb822d83ebe3 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 31 Jul 2024 11:31:32 +0200 Subject: [PATCH 05/19] WIP - topological sort for datanames Update R/teal_data-datanames.R Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> add two tests for topological_sort --- R/join_keys.R | 1 + R/teal_data-class.R | 2 ++ R/teal_data-datanames.R | 15 +++++++++++++++ tests/testthat/test-datanames.R | 31 +++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/R/join_keys.R b/R/join_keys.R index 47fb97836..5a1265233 100644 --- a/R/join_keys.R +++ b/R/join_keys.R @@ -142,6 +142,7 @@ join_keys.teal_data <- function(...) { #' join_keys(td) `join_keys<-.teal_data` <- function(x, value) { join_keys(x@join_keys) <- value + x@datanames <- sort_datanames(x@datanames, x@join_keys) x } diff --git a/R/teal_data-class.R b/R/teal_data-class.R index 542ee76bb..eca5307b6 100644 --- a/R/teal_data-class.R +++ b/R/teal_data-class.R @@ -82,6 +82,8 @@ new_teal_data <- function(data, new_env <- rlang::env_clone(list2env(data), parent = parent.env(.GlobalEnv)) lockEnvironment(new_env, bindings = TRUE) + datanames <- sort_datanames(datanames, join_keys) + methods::new( "teal_data", env = new_env, diff --git a/R/teal_data-datanames.R b/R/teal_data-datanames.R index 929f09eb1..613bba482 100644 --- a/R/teal_data-datanames.R +++ b/R/teal_data-datanames.R @@ -43,6 +43,7 @@ setGeneric("datanames<-", function(x, value) standardGeneric("datanames<-")) setMethod("datanames<-", signature = c("teal_data", "character"), definition = function(x, value) { checkmate::assert_subset(value, names(x@env)) x@datanames <- value + x@datanames <- sort_datanames(x@datanames, x@join_keys) methods::validObject(x) x }) @@ -50,3 +51,17 @@ setMethod("datanames<-", signature = c("qenv.error", "character"), definition = methods::validObject(x) x }) + + +#' @keywords internal +sort_datanames <- function(datanames, joinkeys) { + + child_parent <- sapply( + datanames, + function(name) teal.data::parent(joinkeys, name), + USE.NAMES = TRUE, + simplify = FALSE + ) + + union(unlist(topological_sort(child_parent)), datanames) +} diff --git a/tests/testthat/test-datanames.R b/tests/testthat/test-datanames.R index 68966006f..9d5f982db 100644 --- a/tests/testthat/test-datanames.R +++ b/tests/testthat/test-datanames.R @@ -41,3 +41,34 @@ testthat::test_that("datanames<- called on qenv.error does not change qenv.error qec <- qe testthat::expect_identical(qe, qec) }) + +# topological_order ---- +testthat::test_that("datanames return topological order of datasets once join_keys are specified", { + data <- within(teal_data(), { + ADTTE <- teal.data::rADTTE + iris <- iris + ADSL <- teal.data::rADSL + }) + datanames(data) <- c("ADTTE", "iris", "ADSL") + join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] + testthat::expect_identical( + datanames(data), + c("ADSL", "ADTTE", "iris") + ) +}) + +testthat::test_that("datanames return topological order of datasets after datanames are caled after join_keys", { + data <- within(teal_data(), { + ADTTE <- teal.data::rADTTE + iris <- iris + ADSL <- teal.data::rADSL + }) + + join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] + datanames(data) <- c("ADTTE", "iris", "ADSL") + + testthat::expect_identical( + datanames(data), + c("ADSL", "ADTTE", "iris") + ) +}) From 3050093bbcfa04b08464058c3e86bf9679fa52c8 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:40:09 +0200 Subject: [PATCH 06/19] Update R/teal_data-datanames.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/teal_data-datanames.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/teal_data-datanames.R b/R/teal_data-datanames.R index 613bba482..b680ec6d0 100644 --- a/R/teal_data-datanames.R +++ b/R/teal_data-datanames.R @@ -58,7 +58,7 @@ sort_datanames <- function(datanames, joinkeys) { child_parent <- sapply( datanames, - function(name) teal.data::parent(joinkeys, name), + function(name) parent(joinkeys, name), USE.NAMES = TRUE, simplify = FALSE ) From c8ebd8249b6736ac8fa1e0009060eb9a2dd37700 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:18:18 +0000 Subject: [PATCH 07/19] [skip style] [skip vbump] Restyle files --- R/teal_data-datanames.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/teal_data-datanames.R b/R/teal_data-datanames.R index b680ec6d0..7ddf0fd29 100644 --- a/R/teal_data-datanames.R +++ b/R/teal_data-datanames.R @@ -55,7 +55,6 @@ setMethod("datanames<-", signature = c("qenv.error", "character"), definition = #' @keywords internal sort_datanames <- function(datanames, joinkeys) { - child_parent <- sapply( datanames, function(name) parent(joinkeys, name), From 8a84286f80cc55ece60685881841aa6020f5ac2c Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 31 Jul 2024 12:20:20 +0200 Subject: [PATCH 08/19] datanames() test for join_keys set during teal_data creation --- tests/testthat/test-datanames.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testthat/test-datanames.R b/tests/testthat/test-datanames.R index 9d5f982db..4224f5995 100644 --- a/tests/testthat/test-datanames.R +++ b/tests/testthat/test-datanames.R @@ -43,6 +43,16 @@ testthat::test_that("datanames<- called on qenv.error does not change qenv.error }) # topological_order ---- + +testthat::test_that("datanames are set in topological in constructor if join_keys are specified", { + data <- + teal_data(b = data.frame(), a = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) + testthat::expect_identical( + datanames(data), + c("a", "b") + ) +}) + testthat::test_that("datanames return topological order of datasets once join_keys are specified", { data <- within(teal_data(), { ADTTE <- teal.data::rADTTE From ee389a5d6fbb62e063757ced6ed43b1b26e03013 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:24:23 +0000 Subject: [PATCH 09/19] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index defb57aec..575647989 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,7 +54,7 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Collate: 'cdisc_data.R' 'data.R' From f6be3110462fa1be3c7de6f0b1561178a0c1d2a8 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Wed, 31 Jul 2024 13:34:17 +0200 Subject: [PATCH 10/19] set safely --- R/join_keys.R | 2 +- R/teal_data-class.R | 2 +- R/teal_data-datanames.R | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/R/join_keys.R b/R/join_keys.R index 5a1265233..1798a46af 100644 --- a/R/join_keys.R +++ b/R/join_keys.R @@ -142,7 +142,7 @@ join_keys.teal_data <- function(...) { #' join_keys(td) `join_keys<-.teal_data` <- function(x, value) { join_keys(x@join_keys) <- value - x@datanames <- sort_datanames(x@datanames, x@join_keys) + datanames(x) <- x@datanames # datanames fun manages some exceptions x } diff --git a/R/teal_data-class.R b/R/teal_data-class.R index eca5307b6..953cd807c 100644 --- a/R/teal_data-class.R +++ b/R/teal_data-class.R @@ -82,7 +82,7 @@ new_teal_data <- function(data, new_env <- rlang::env_clone(list2env(data), parent = parent.env(.GlobalEnv)) lockEnvironment(new_env, bindings = TRUE) - datanames <- sort_datanames(datanames, join_keys) + datanames <- .get_sorted_datanames(datanames = datanames, join_keys = join_keys, env = env) methods::new( "teal_data", diff --git a/R/teal_data-datanames.R b/R/teal_data-datanames.R index 7ddf0fd29..d32727859 100644 --- a/R/teal_data-datanames.R +++ b/R/teal_data-datanames.R @@ -42,8 +42,7 @@ setMethod("datanames", signature = "qenv.error", definition = function(x) { setGeneric("datanames<-", function(x, value) standardGeneric("datanames<-")) setMethod("datanames<-", signature = c("teal_data", "character"), definition = function(x, value) { checkmate::assert_subset(value, names(x@env)) - x@datanames <- value - x@datanames <- sort_datanames(x@datanames, x@join_keys) + x@datanames <- .get_sorted_datanames(datanames = value, join_keys = x@join_keys, env = x@env) methods::validObject(x) x }) @@ -54,13 +53,16 @@ setMethod("datanames<-", signature = c("qenv.error", "character"), definition = #' @keywords internal -sort_datanames <- function(datanames, joinkeys) { +.get_sorted_datanames <- function(datanames, join_keys, env) { child_parent <- sapply( datanames, - function(name) parent(joinkeys, name), + function(name) parent(join_keys, name), USE.NAMES = TRUE, simplify = FALSE ) - union(unlist(topological_sort(child_parent)), datanames) + union( + intersect(unlist(topological_sort(child_parent)), ls(env)), + datanames + ) } From a3ece0e1bfdafbf2124fa7ffc3adfa00d4336964 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 31 Jul 2024 14:12:54 +0200 Subject: [PATCH 11/19] typo --- R/teal_data-class.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/teal_data-class.R b/R/teal_data-class.R index 953cd807c..81bbc8fd3 100644 --- a/R/teal_data-class.R +++ b/R/teal_data-class.R @@ -82,7 +82,7 @@ new_teal_data <- function(data, new_env <- rlang::env_clone(list2env(data), parent = parent.env(.GlobalEnv)) lockEnvironment(new_env, bindings = TRUE) - datanames <- .get_sorted_datanames(datanames = datanames, join_keys = join_keys, env = env) + datanames <- .get_sorted_datanames(datanames = datanames, join_keys = join_keys, env = new_env) methods::new( "teal_data", From b395c2924f590cf1a100cae7bd64be2aa8b59270 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 31 Jul 2024 14:25:19 +0200 Subject: [PATCH 12/19] add more tests for datanames() and do not extract datanames() from join_keys as they might refer to datanames that do not exist in env --- R/teal_data-class.R | 2 +- tests/testthat/test-datanames.R | 54 +++++++++++++++++++++++++++++++-- tests/testthat/test-teal_data.R | 14 +++++---- 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/R/teal_data-class.R b/R/teal_data-class.R index 81bbc8fd3..3015797b9 100644 --- a/R/teal_data-class.R +++ b/R/teal_data-class.R @@ -60,7 +60,7 @@ setClass( new_teal_data <- function(data, code = character(0), join_keys = join_keys(), - datanames = union(names(data), names(join_keys))) { + datanames = names(data)) { checkmate::assert_list(data) checkmate::assert_class(join_keys, "join_keys") if (is.null(datanames)) datanames <- character(0) # todo: allow to specify diff --git a/tests/testthat/test-datanames.R b/tests/testthat/test-datanames.R index 4224f5995..283d4dc13 100644 --- a/tests/testthat/test-datanames.R +++ b/tests/testthat/test-datanames.R @@ -44,7 +44,7 @@ testthat::test_that("datanames<- called on qenv.error does not change qenv.error # topological_order ---- -testthat::test_that("datanames are set in topological in constructor if join_keys are specified", { +testthat::test_that("datanames are set in topological order in constructor if join_keys are specified", { data <- teal_data(b = data.frame(), a = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) testthat::expect_identical( @@ -53,6 +53,25 @@ testthat::test_that("datanames are set in topological in constructor if join_key ) }) +testthat::test_that("datanames return parent if in constructor it was provided in join_keys and exists in env", { + data <- + teal_data(b = data.frame(), a = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) + datanames(data) <- "b" + testthat::expect_identical( + datanames(data), + c("a", "b") + ) +}) + +testthat::test_that("datanames do not return parent if in constructor it was provided in join_keys but do not exists in env", { + data <- + teal_data(b = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) + testthat::expect_identical( + datanames(data), + "b" + ) +}) + testthat::test_that("datanames return topological order of datasets once join_keys are specified", { data <- within(teal_data(), { ADTTE <- teal.data::rADTTE @@ -67,7 +86,7 @@ testthat::test_that("datanames return topological order of datasets once join_ke ) }) -testthat::test_that("datanames return topological order of datasets after datanames are caled after join_keys", { +testthat::test_that("datanames return topological order of datasets after datanames are called after join_keys", { data <- within(teal_data(), { ADTTE <- teal.data::rADTTE iris <- iris @@ -82,3 +101,34 @@ testthat::test_that("datanames return topological order of datasets after datana c("ADSL", "ADTTE", "iris") ) }) + + +testthat::test_that("datanames return parent if join_keys were provided and parent exists in env", { + data <- within(teal_data(), { + ADTTE <- teal.data::rADTTE + iris <- iris + ADSL <- teal.data::rADSL + }) + + join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] + datanames(data) <- c("ADTTE", "iris") + + testthat::expect_identical( + datanames(data), + c("ADSL", "ADTTE", "iris") + ) +}) + +testthat::test_that("datanames do not return parent if join_keys were provided and parent did not exists in env", { + data <- teal_data( + ADTTE = teal.data::rADTTE, + iris = iris + ) + + join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] + + testthat::expect_identical( + datanames(data), + c("ADTTE", "iris") + ) +}) diff --git a/tests/testthat/test-teal_data.R b/tests/testthat/test-teal_data.R index 72c7e7e3b..a0bad8dde 100644 --- a/tests/testthat/test-teal_data.R +++ b/tests/testthat/test-teal_data.R @@ -28,17 +28,19 @@ testthat::test_that("teal_data initializes teal_data object with @datanames take ) }) -testthat::test_that("teal_data initializes teal_data object with @datanames taken from passed join_keys", { +testthat::test_that( + "teal_data initializes teal_data object without @datanames taken from join_keys if objects did not exist in env", { testthat::expect_identical( - teal_data(join_keys = join_keys(join_key("parent", "child", "id")))@datanames, - c("parent", "child") + datanames(teal_data(join_keys = join_keys(join_key("parent", "child", "id")))), + character(0) ) }) -testthat::test_that("teal_data initializes teal_data object with @datanames taken from join_keys and passed objects", { +testthat::test_that( + "teal_data initializes teal_data object with @datanames taken only from passed objects and not join_keys", { testthat::expect_identical( - teal_data(iris = iris, join_keys = join_keys(join_key("parent", "child", "id")))@datanames, - c("iris", "parent", "child") + datanames(teal_data(iris = iris, join_keys = join_keys(join_key("parent", "child", "id")))), + "iris" ) }) From 93c211771cf5f10878c88d64b22682e7d14e989a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:31:56 +0000 Subject: [PATCH 13/19] [skip style] [skip vbump] Restyle files --- tests/testthat/test-teal_data.R | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/testthat/test-teal_data.R b/tests/testthat/test-teal_data.R index a0bad8dde..8391f72e2 100644 --- a/tests/testthat/test-teal_data.R +++ b/tests/testthat/test-teal_data.R @@ -29,20 +29,24 @@ testthat::test_that("teal_data initializes teal_data object with @datanames take }) testthat::test_that( - "teal_data initializes teal_data object without @datanames taken from join_keys if objects did not exist in env", { - testthat::expect_identical( - datanames(teal_data(join_keys = join_keys(join_key("parent", "child", "id")))), - character(0) - ) -}) + "teal_data initializes teal_data object without @datanames taken from join_keys if objects did not exist in env", + { + testthat::expect_identical( + datanames(teal_data(join_keys = join_keys(join_key("parent", "child", "id")))), + character(0) + ) + } +) testthat::test_that( - "teal_data initializes teal_data object with @datanames taken only from passed objects and not join_keys", { - testthat::expect_identical( - datanames(teal_data(iris = iris, join_keys = join_keys(join_key("parent", "child", "id")))), - "iris" - ) -}) + "teal_data initializes teal_data object with @datanames taken only from passed objects and not join_keys", + { + testthat::expect_identical( + datanames(teal_data(iris = iris, join_keys = join_keys(join_key("parent", "child", "id")))), + "iris" + ) + } +) testthat::test_that("teal_data returns teal_data when data passed as named list", { From 4d465245113b86284bae8029c761d1e741ffc86d Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:35:17 +0000 Subject: [PATCH 14/19] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/new_teal_data.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/new_teal_data.Rd b/man/new_teal_data.Rd index 176a04ae5..4ddc43c95 100644 --- a/man/new_teal_data.Rd +++ b/man/new_teal_data.Rd @@ -8,7 +8,7 @@ new_teal_data( data, code = character(0), join_keys = join_keys(), - datanames = union(names(data), names(join_keys)) + datanames = names(data) ) } \arguments{ From 81529f3adfb23297ba5ebca07b42f6099ad1a67a Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 1 Aug 2024 11:04:30 +0200 Subject: [PATCH 15/19] enhance news --- NEWS.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NEWS.md b/NEWS.md index 8f7933a14..a8154dacc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,15 @@ # teal.data 0.6.0.9005 +### Enhancements + +- `datanames()` + - if `join_keys` are provided, the `datanames()` are now sorted in topological way (Kahn algorithm), + which means the parent dataset always precedes the child dataset. + - are extended by the parent dataset name, if one of the child dataset exist in `datanames()` and + the connection between child-parent is set through `join_keys` and `parent` exist in `teal_data` environment. + - do not allow to set a dataset name that do not exist in `teal_data` environment. + - `teal_data` no longer set default `datanames()` based on `join_keys` names - it uses only data names. + # teal.data 0.6.0 ### Enhancements From 0ecb6178e2d522398c632357c6b26e46cdd58e6e Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 1 Aug 2024 11:06:47 +0200 Subject: [PATCH 16/19] superlintr fixes --- tests/testthat/test-datanames.R | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-datanames.R b/tests/testthat/test-datanames.R index 283d4dc13..9ed90f837 100644 --- a/tests/testthat/test-datanames.R +++ b/tests/testthat/test-datanames.R @@ -63,7 +63,8 @@ testthat::test_that("datanames return parent if in constructor it was provided i ) }) -testthat::test_that("datanames do not return parent if in constructor it was provided in join_keys but do not exists in env", { +testthat::test_that( + "datanames do not return parent if in constructor it was provided in join_keys but do not exists in env", { data <- teal_data(b = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) testthat::expect_identical( @@ -74,9 +75,9 @@ testthat::test_that("datanames do not return parent if in constructor it was pro testthat::test_that("datanames return topological order of datasets once join_keys are specified", { data <- within(teal_data(), { - ADTTE <- teal.data::rADTTE + ADTTE <- teal.data::rADTTE # nolint: object_name. iris <- iris - ADSL <- teal.data::rADSL + ADSL <- teal.data::rADSL # nolint: object_name. }) datanames(data) <- c("ADTTE", "iris", "ADSL") join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] @@ -88,9 +89,9 @@ testthat::test_that("datanames return topological order of datasets once join_ke testthat::test_that("datanames return topological order of datasets after datanames are called after join_keys", { data <- within(teal_data(), { - ADTTE <- teal.data::rADTTE + ADTTE <- teal.data::rADTTE # nolint: object_name. iris <- iris - ADSL <- teal.data::rADSL + ADSL <- teal.data::rADSL # nolint: object_name. }) join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] @@ -105,9 +106,9 @@ testthat::test_that("datanames return topological order of datasets after datana testthat::test_that("datanames return parent if join_keys were provided and parent exists in env", { data <- within(teal_data(), { - ADTTE <- teal.data::rADTTE + ADTTE <- teal.data::rADTTE # nolint: object_name. iris <- iris - ADSL <- teal.data::rADSL + ADSL <- teal.data::rADSL # nolint: object_name. }) join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] @@ -121,7 +122,7 @@ testthat::test_that("datanames return parent if join_keys were provided and pare testthat::test_that("datanames do not return parent if join_keys were provided and parent did not exists in env", { data <- teal_data( - ADTTE = teal.data::rADTTE, + ADTTE = teal.data::rADTTE, # nolint: object_name. iris = iris ) From 480df2c861a07c98ac8f7cda5f3982ab8791cf40 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:08:45 +0000 Subject: [PATCH 17/19] [skip style] [skip vbump] Restyle files --- tests/testthat/test-datanames.R | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-datanames.R b/tests/testthat/test-datanames.R index 9ed90f837..e0c99bb63 100644 --- a/tests/testthat/test-datanames.R +++ b/tests/testthat/test-datanames.R @@ -64,14 +64,16 @@ testthat::test_that("datanames return parent if in constructor it was provided i }) testthat::test_that( - "datanames do not return parent if in constructor it was provided in join_keys but do not exists in env", { - data <- - teal_data(b = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) - testthat::expect_identical( - datanames(data), - "b" - ) -}) + "datanames do not return parent if in constructor it was provided in join_keys but do not exists in env", + { + data <- + teal_data(b = data.frame(), join_keys = join_keys(join_key("a", "b", "id"))) + testthat::expect_identical( + datanames(data), + "b" + ) + } +) testthat::test_that("datanames return topological order of datasets once join_keys are specified", { data <- within(teal_data(), { From c61416e8455ec3328a7c8397f07d950dc8cc190a Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 1 Aug 2024 11:34:48 +0200 Subject: [PATCH 18/19] quote Kahn --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a8154dacc..acc28f102 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ ### Enhancements - `datanames()` - - if `join_keys` are provided, the `datanames()` are now sorted in topological way (Kahn algorithm), + - if `join_keys` are provided, the `datanames()` are now sorted in topological way (`Kahn` algorithm), which means the parent dataset always precedes the child dataset. - are extended by the parent dataset name, if one of the child dataset exist in `datanames()` and the connection between child-parent is set through `join_keys` and `parent` exist in `teal_data` environment. From b9dd005484e2f9c7a95a8523f9e95109ddd295ec Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 1 Aug 2024 12:01:34 +0200 Subject: [PATCH 19/19] extend Wordlist --- inst/WORDLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index f53064cb2..6860ac2d2 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -3,6 +3,7 @@ CDISC Forkers Getter Hoffmann +Kahn ORCID Reproducibility formatters