Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JoinKeys related changes due to refactor #160

Merged
merged 15 commits into from
Nov 20, 2023
2 changes: 1 addition & 1 deletion R/choices_labeled.R
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ value_choices.data.frame <- function(data, # nolint
df_choices <- dplyr::mutate_if(
df_choices,
.predicate = function(col) inherits(col, c("POSIXct", "POSIXlt", "POSIXt")),
.fun = function(col) {
.funs = function(col) {
if (is.null(attr(col, "tzone")) || all(attr(col, "tzone") == "")) {
format(trunc(col), "%Y-%m-%d %H:%M:%S")
} else {
Expand Down
8 changes: 4 additions & 4 deletions R/data_extract_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ data_extract_srv.list <- function(id, datasets, data_extract_spec, join_keys = N

# get keys out of join_keys
if (!is.null(join_keys)) {
keys <- sapply(names(datasets), simplify = FALSE, function(x) join_keys$get(x, x))
keys <- sapply(names(datasets), simplify = FALSE, function(x) join_keys[x, x])
} else {
keys <- sapply(names(datasets), simplify = FALSE, function(x) character(0))
}
Expand Down Expand Up @@ -704,15 +704,15 @@ data_extract_multiple_srv.list <- function(data_extract, datasets, join_keys = N
checkmate::assert_list(datasets, types = c("reactive", "data.frame"), names = "named")
checkmate::assert_class(join_keys, "JoinKeys", null.ok = TRUE)
checkmate::assert(
checkmate::check_multi_class(select_validation_rule, class = c("function", "formula"), null.ok = TRUE),
checkmate::check_multi_class(select_validation_rule, classes = c("function", "formula"), null.ok = TRUE),
checkmate::check_list(select_validation_rule, types = c("function", "formula", "NULL"), null.ok = TRUE)
)
checkmate::assert(
checkmate::check_multi_class(filter_validation_rule, class = c("function", "formula"), null.ok = TRUE),
checkmate::check_multi_class(filter_validation_rule, classes = c("function", "formula"), null.ok = TRUE),
checkmate::check_list(filter_validation_rule, types = c("function", "formula", "NULL"), null.ok = TRUE)
)
checkmate::assert(
checkmate::check_multi_class(dataset_validation_rule, class = c("function", "formula"), null.ok = TRUE),
checkmate::check_multi_class(dataset_validation_rule, classes = c("function", "formula"), null.ok = TRUE),
checkmate::check_list(dataset_validation_rule, types = c("function", "formula", "NULL"), null.ok = TRUE)
)

Expand Down
2 changes: 1 addition & 1 deletion R/get_merge_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ get_merge_key_grid <- function(selector_list, join_keys = teal.data::join_keys()
get_merge_key_pair(
selector_from,
selector_to,
join_keys$get(selector_from$dataname, selector_to$dataname)
join_keys[selector_from$dataname, selector_to$dataname]
vedhav marked this conversation as resolved.
Show resolved Hide resolved
)
}
)
Expand Down
2 changes: 1 addition & 1 deletion R/merge_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ are_needed_keys_provided <- function(join_keys, merged_selector_list) {
}

do_join_keys_exist <- function(dataset_name1, dataset_name2, join_keys) {
length(join_keys$get(dataset_name1, dataset_name2) > 0)
length(join_keys[dataset_name1, dataset_name2] > 0)
}

datasets_names <- vapply(merged_selector_list, function(slice) slice[["dataname"]], FUN.VALUE = character(1))
Expand Down
2 changes: 1 addition & 1 deletion R/resolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#' teal.transform:::resolve(arm_ref_comp, data_list, keys)
#' })
resolve <- function(x, datasets, keys = NULL) {
checkmate::assert_list(datasets, type = "reactive", min.len = 1, names = "named")
checkmate::assert_list(datasets, types = "reactive", min.len = 1, names = "named")
checkmate::assert_list(keys, "character", names = "named", null.ok = TRUE)
checkmate::assert(
.var.name = "keys",
Expand Down
2 changes: 1 addition & 1 deletion R/resolve_delayed.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ resolve_delayed.FilteredData <- function(x,

#' @export
resolve_delayed.list <- function(x, datasets, keys = NULL) {
checkmate::assert_list(datasets, type = c("reactive", "data.frame"), min.len = 1, names = "named")
checkmate::assert_list(datasets, types = c("reactive", "data.frame"), min.len = 1, names = "named")
checkmate::assert_list(keys, "character", names = "named", null.ok = TRUE)
checkmate::assert(
.var.name = "keys",
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-merge_expression_srv.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ adsl_data_extract_srv_output <-
dataname = "ADSL",
filters = NULL,
select = "AGE",
keys = join_keys$get("ADSL", "ADSL"),
keys = join_keys["ADSL", "ADSL"],
reshape = FALSE,
internal_id = "adsl_extract"
)
Expand All @@ -30,7 +30,7 @@ adlb_data_extract_srv_output <-
dataname = "ADLB",
filters = NULL,
select = c("AVAL", "CHG"),
keys = join_keys$get("ADLB", "ADLB"),
keys = join_keys["ADLB", "ADLB"],
reshape = FALSE,
internal_id = "adlb_extract"
)
Expand Down