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

options for strict tests; few enhancements #250

Merged
merged 12 commits into from
Mar 4, 2024
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Suggests:
nestcolor (>= 0.1.0),
rmarkdown,
teal.data (>= 0.3.0.9018),
testthat (>= 3.1.5)
testthat (>= 3.1.5),
withr (>= 2.0.0)
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
Expand Down
2 changes: 0 additions & 2 deletions R/teal.osprey.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
#' The \code{teal.osprey} R package contains interactive \code{\link{teal}} modules for the outputs
#'
#' @import dplyr osprey shiny teal formatters teal.transform
#' @name teal.osprey
#' @keywords internal
#'
"_PACKAGE"
4 changes: 2 additions & 2 deletions R/tm_g_ae_sub.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#' tm_g_ae_sub(
#' label = "AE by Subgroup",
#' dataname = "ADAE",
#' arm_var = teal.transform::choices_selected(
#' arm_var = choices_selected(
#' selected = "ACTARMCD",
#' choices = c("ACTARM", "ACTARMCD")
#' ),
#' group_var = teal.transform::choices_selected(
#' group_var = choices_selected(
#' selected = c("SEX", "REGION1", "RACE"),
#' choices = c("SEX", "REGION1", "RACE")
#' ),
Expand Down
1 change: 1 addition & 0 deletions R/tm_g_heat_bygrade.R
chlebowa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ srv_g_heatmap_bygrade <- function(id,
ADSL <- data()[[sl_dataname]] # nolint
ADEX <- data()[[ex_dataname]] # nolint
ADAE <- data()[[ae_dataname]] # nolint
ADCM <- data()[[cm_dataname]] # nolint

teal::validate_has_data(ADSL, min_nrow = 1, msg = sprintf("%s contains no data", sl_dataname))
teal::validate_inputs(iv(), iv_cm())
Expand Down
37 changes: 18 additions & 19 deletions R/tm_g_swimlane.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,52 @@
#'
#' @examples
#' # Example using stream (ADaM) dataset
#' data <- teal.data::cdisc_data() |>
#' data <- cdisc_data() |>
#' within(library(dplyr)) |>
#' within(library(nestcolor)) |>
#' within(ADSL <- osprey::rADSL %>%
#' dplyr::mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>%
#' dplyr::filter(STRATA1 == "A" & ARMCD == "ARM A")) |>
#' within(ADRS <- osprey::rADRS) |>
#' within(ADRS <- ADRS %>%
#' dplyr::filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>%
#' within(ADSL <- rADSL %>%
#' mutate(TRTDURD = as.integer(TRTEDTM - TRTSDTM) + 1) %>%
#' filter(STRATA1 == "A" & ARMCD == "ARM A")) |>
#' within(ADRS <- rADRS %>%
#' filter(PARAMCD == "LSTASDI" & DCSREAS == "Death") %>%
#' mutate(AVALC = DCSREAS, ADY = EOSDY) %>%
#' base::rbind(ADRS %>% dplyr::filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>%
#' rbind(rADRS %>% filter(PARAMCD == "OVRINV" & AVALC != "NE")) %>%
#' arrange(USUBJID))
#'
#' teal.data::datanames(data) <- c("ADSL", "ADRS")
#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[teal.data::datanames(data)]
#' datanames(data) <- c("ADSL", "ADRS")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- data[["ADSL"]]
#' ADRS <- data[["ADRS"]]
#'
#' app <- teal::init(
#' app <- init(
#' data = data,
#' modules = teal::modules(
#' modules = modules(
#' tm_g_swimlane(
#' label = "Swimlane Plot",
#' dataname = "ADRS",
#' bar_var = teal.transform::choices_selected(
#' bar_var = choices_selected(
#' selected = "TRTDURD",
#' choices = c("TRTDURD", "EOSDY")
#' ),
#' bar_color_var = teal.transform::choices_selected(
#' bar_color_var = choices_selected(
#' selected = "EOSSTT",
#' choices = c("EOSSTT", "ARM", "ARMCD", "ACTARM", "ACTARMCD", "SEX")
#' ),
#' sort_var = teal.transform::choices_selected(
#' sort_var = choices_selected(
#' selected = "ACTARMCD",
#' choices = c("USUBJID", "SITEID", "ACTARMCD", "TRTDURD")
#' ),
#' marker_pos_var = teal.transform::choices_selected(
#' marker_pos_var = choices_selected(
#' selected = "ADY",
#' choices = c("ADY")
#' ),
#' marker_shape_var = teal.transform::choices_selected(
#' marker_shape_var = choices_selected(
#' selected = "AVALC",
#' c("AVALC", "AVISIT")
#' ),
#' marker_shape_opt = c("CR" = 16, "PR" = 17, "SD" = 18, "PD" = 15, "Death" = 8),
#' marker_color_var = teal.transform::choices_selected(
#' marker_color_var = choices_selected(
#' selected = "AVALC",
#' choices = c("AVALC", "AVISIT")
#' ),
Expand All @@ -91,7 +90,7 @@
#' "PD" = "red", "Death" = "black"
#' ),
#' vref_line = c(30, 60),
#' anno_txt_var = teal.transform::choices_selected(
#' anno_txt_var = choices_selected(
#' selected = c("ACTARM", "SEX"),
#' choices = c(
#' "ARM", "ARMCD", "ACTARM", "ACTARMCD", "AGEGR1",
Expand Down
4 changes: 2 additions & 2 deletions man/teal.osprey.Rd → man/teal.osprey-package.Rd

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

4 changes: 2 additions & 2 deletions man/tm_g_ae_sub.Rd

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

37 changes: 18 additions & 19 deletions man/tm_g_swimlane.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/setup-logger.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logger::log_appender(function(...) NULL, namespace = "teal.osprey")
20 changes: 20 additions & 0 deletions tests/testthat/setup-options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
# it might happen that it is not used right now, but it is left for possible future use
# use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test
opts_partial_match_old <- list(
warnPartialMatchDollar = getOption("warnPartialMatchDollar"),
warnPartialMatchArgs = getOption("warnPartialMatchArgs"),
warnPartialMatchAttr = getOption("warnPartialMatchAttr")
)
opts_partial_match_new <- list(
warnPartialMatchDollar = TRUE,
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE
)

if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) {
withr::local_options(
opts_partial_match_new,
.local_envir = testthat::teardown_env()
)
}
Loading