From 2b9da8e089451f3dd59a9d2aa52d3aababe3a261 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Fri, 8 Nov 2024 13:32:03 +0100 Subject: [PATCH] postmerge fixes --- R/join_keys-extract.R | 6 +++--- R/teal_data-class.R | 2 +- R/teal_data-get_code.R | 2 +- R/teal_data-names.R | 8 ++++---- man/join_keys.Rd | 6 +++--- man/teal_data-class.Rd | 14 ++------------ tests/testthat/test-teal_data.R | 2 +- tests/testthat/test-verify.R | 2 +- 8 files changed, 16 insertions(+), 26 deletions(-) diff --git a/R/join_keys-extract.R b/R/join_keys-extract.R index 46e2c73b1..a533c5045 100644 --- a/R/join_keys-extract.R +++ b/R/join_keys-extract.R @@ -2,9 +2,9 @@ #' @order 2 #' #' @section Functions: -#' - `x[datanames]`: Returns a subset of the `join_keys` object for -#' given `datanames`, including parent `datanames` and symmetric mirror keys between -#' `datanames` in the result. +#' - `x[names]`: Returns a subset of the `join_keys` object for +#' given `names`, including parent `names` and symmetric mirror keys between +#' `names` in the result. #' - `x[i, j]`: Returns join keys between datasets `i` and `j`, #' including implicit keys inferred from their relationship with a parent. #' diff --git a/R/teal_data-class.R b/R/teal_data-class.R index 460f9b798..85ce9e3bc 100644 --- a/R/teal_data-class.R +++ b/R/teal_data-class.R @@ -18,7 +18,7 @@ setOldClass("join_keys") #' auxiliary variables. #' Access variables with [get()], [`$`], [get_var()] or [`[[`]. #' No setter provided. Evaluate code to add variables into `@.xData`. -#' @slot code (`list` of `character`) representing code necessary to reproduce the contents of `@env`. +#' @slot code (`list` of `character`) representing code necessary to reproduce the contents of `qenv`. #' Access with [get_code()]. #' No setter provided. Evaluate code to append code to the slot. #' @slot join_keys (`join_keys`) object specifying joining keys for data sets in diff --git a/R/teal_data-get_code.R b/R/teal_data-get_code.R index 23002590d..52c237a71 100644 --- a/R/teal_data-get_code.R +++ b/R/teal_data-get_code.R @@ -121,7 +121,7 @@ setMethod("get_code", } if (!is.null(names) && lifecycle::is_present(datanames)) { - stop("Please use either 'names' (recommended) or 'datanames' parameter.") + stop("'names' shouldn't be specified with deprecated 'datanames' parameter.") } checkmate::assert_character(names, min.len = 1L, null.ok = TRUE) diff --git a/R/teal_data-names.R b/R/teal_data-names.R index 32e9d71de..1c28ccd56 100644 --- a/R/teal_data-names.R +++ b/R/teal_data-names.R @@ -24,18 +24,18 @@ names.teal_data <- function(x) { # Sorting from `ls` can be safely done as environments don't have any order # nor support numeric-index subsetting envir <- as.environment(x) - .get_sorted_names(ls(envir = envir), join_keys(x), envir) + .get_sorted_names(names = ls(envir = envir), join_keys = join_keys(x), env = envir) } #' @export length.teal.data <- function(x) length(ls(x)) #' @keywords internal -.get_sorted_names <- function(datanames, join_keys, env) { - child_parent <- sapply(datanames, parent, x = join_keys, USE.NAMES = TRUE, simplify = FALSE) +.get_sorted_names <- function(names, join_keys, env) { + child_parent <- sapply(names, parent, x = join_keys, USE.NAMES = TRUE, simplify = FALSE) union( intersect(unlist(topological_sort(child_parent)), ls(env, all.names = TRUE)), - datanames + names ) } diff --git a/man/join_keys.Rd b/man/join_keys.Rd index bc1e9a15f..df13905bf 100644 --- a/man/join_keys.Rd +++ b/man/join_keys.Rd @@ -101,9 +101,9 @@ in a parent-child relationship and the mapping is automatically mirrored between \section{Functions}{ \itemize{ -\item \code{x[datanames]}: Returns a subset of the \code{join_keys} object for -given \code{datanames}, including parent \code{datanames} and symmetric mirror keys between -\code{datanames} in the result. +\item \code{x[names]}: Returns a subset of the \code{join_keys} object for +given \code{names}, including parent \code{names} and symmetric mirror keys between +\code{names} in the result. \item \code{x[i, j]}: Returns join keys between datasets \code{i} and \code{j}, including implicit keys inferred from their relationship with a parent. } diff --git a/man/teal_data-class.Rd b/man/teal_data-class.Rd index ce613ff60..86da5a14c 100644 --- a/man/teal_data-class.Rd +++ b/man/teal_data-class.Rd @@ -23,19 +23,9 @@ auxiliary variables. Access variables with \code{\link[=get]{get()}}, \code{\link{$}}, \code{\link[=get_var]{get_var()}} or [\code{[[}]. No setter provided. Evaluate code to add variables into \verb{@.xData}.} -\item{\code{code}}{(\code{character}) vector representing code necessary to reproduce the -contents of \verb{@.xData}. +\item{\code{code}}{(\code{list} of \code{character}) representing code necessary to reproduce the contents of \code{qenv}. Access with \code{\link[=get_code]{get_code()}}. -No setter provided. Evaluate code to append code to the slot. -Read more in Code section.} - -\item{\code{id}}{(\code{integer}) random identifier assigned to each element of \verb{@code}. -Used internally.} - -\item{\code{warnings}}{(\code{character}) vector of warnings raised when evaluating code. -Access with \code{\link[=get_warnings]{get_warnings()}}.} - -\item{\code{messages}}{(\code{character}) vector of messages raised when evaluating code.} +No setter provided. Evaluate code to append code to the slot.} \item{\code{join_keys}}{(\code{join_keys}) object specifying joining keys for data sets in \verb{@.xData}. diff --git a/tests/testthat/test-teal_data.R b/tests/testthat/test-teal_data.R index 46439c7d8..268bf11c3 100644 --- a/tests/testthat/test-teal_data.R +++ b/tests/testthat/test-teal_data.R @@ -3,7 +3,7 @@ testthat::test_that("teal_data allows to initialize empty teal_data object", { }) testthat::test_that("empty teal_data returns empty code and verified=TRUE", { - testthat::expect_identical(teal_data()@code, list(character(0))) + testthat::expect_identical(teal_data()@code, list()) testthat::expect_identical(teal_data()@verified, TRUE) }) diff --git a/tests/testthat/test-verify.R b/tests/testthat/test-verify.R index 4e15fb696..f80537895 100644 --- a/tests/testthat/test-verify.R +++ b/tests/testthat/test-verify.R @@ -20,7 +20,7 @@ testthat::test_that("verify returns the same object with changed @verified field testthat::expect_identical(teal.code::get_env(tdata2_ver), teal.code::get_env(tdata2)) }) -testthat::test_that("verify raises error if @code does not restore objects in @env", { +testthat::test_that("verify raises error if @code does not restore objects in @.xData", { tdata3 <- teal_data(x1 = iris, code = "x1 = mtcars") testthat::expect_error(verify(tdata3), "Code verification failed.")