Skip to content

Commit

Permalink
postmerge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 8, 2024
1 parent e31d65a commit 2b9da8e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 26 deletions.
6 changes: 3 additions & 3 deletions R/join_keys-extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/teal_data-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/teal_data-get_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions R/teal_data-names.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
6 changes: 3 additions & 3 deletions man/join_keys.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions man/teal_data-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-verify.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 2b9da8e

Please sign in to comment.