Skip to content

Commit

Permalink
- rename keys to join_keys in new_teal_data
Browse files Browse the repository at this point in the history
- fill datanames by join keys datanames
  • Loading branch information
gogonzo committed Oct 25, 2023
1 parent 996d080 commit 4c03c22
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
11 changes: 7 additions & 4 deletions R/teal_data-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ setClass(
#' @param data (`named list`) List of data.
#' @param code (`character` or `language`) code to reproduce the `data`.
#' Accepts and stores comments also.
#' @param keys (`JoinKeys`) object
#' @param join_keys (`JoinKeys`) object
#' @param datanames (`character`) names of datasets passed to `data`.
#' Needed when non-dataset objects are needed in the `env` slot.
#' @rdname new_teal_data
#' @keywords internal
new_teal_data <- function(data, code = character(0), keys = join_keys(), datanames = names(data)) {
new_teal_data <- function(data,
code = character(0),
join_keys = join_keys(),
datanames = union(names(data), names(join_keys$get()))) {
checkmate::assert_list(data)
checkmate::assert_class(keys, "JoinKeys")
checkmate::assert_class(join_keys, "JoinKeys")
checkmate::assert_character(datanames)
if (!any(is.language(code), is.character(code))) {
stop("`code` must be a character or language object.")
Expand All @@ -68,7 +71,7 @@ new_teal_data <- function(data, code = character(0), keys = join_keys(), datanam
warnings = "",
messages = "",
id = sample.int(.Machine$integer.max, size = 1L),
join_keys = keys,
join_keys = join_keys,
datanames = datanames
)
}
10 changes: 7 additions & 3 deletions R/teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ teal_data <- function(...,
join_keys <- teal.data::join_keys(join_keys)
}
if (
checkmate::test_list(data_objects, types = c("TealDataConnector", "TealDataset", "TealDatasetConnector"))
checkmate::test_list(
data_objects,
types = c("TealDataConnector", "TealDataset", "TealDatasetConnector"),
min.len = 1
)
) {
lifecycle::deprecate_warn(
when = "0.3.1",
Expand All @@ -59,13 +63,13 @@ teal_data <- function(...,
x$check_metadata()
x
} else {
if (!checkmate::test_names(names(data_objects), type = "named")) {
if (length(data_objects) > 0 && !checkmate::test_names(names(data_objects), type = "named")) {
stop("Dot (`...`) arguments on `teal_data()` must be named.")
}
new_teal_data(
data = data_objects,
code = code,
keys = join_keys
join_keys = join_keys
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions man/new_teal_data.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/helper-get_join_keys.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ helper_generator_teal_data <- function() {
ds2 = iris2
),
code = "ds1 <- iris2; ds2 <- iris2",
keys = helper_generator_JoinKeys("ds1", keys = c("id"))
join_keys = helper_generator_JoinKeys("ds1", keys = c("id"))
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-TealDatasetConnector.R
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ testthat::test_that("code_dataset_connector - library calls", {
label = "ADRS dataset"
)

data <- cdisc_data(adsl, adtte, adrs, check = TRUE)
expect_warning(data <- cdisc_data(adsl, adtte, adrs, check = TRUE), "deprecated")
expect_silent(
lapply(
data$get_items(),
Expand Down

0 comments on commit 4c03c22

Please sign in to comment.