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

740 qplot warning failure@main #741

Merged
merged 9 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions R/decorate_grob.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
#' ## with \code{ggplot2}
#' library(ggplot2)
#'
#' p_gg <- with(iris, qplot(Sepal.Length, Petal.Length, col = Species))
#' p_gg <- ggplot2::ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) +
#' ggplot2::geom_point()
#' p_gg
#' p <- ggplotGrob(p_gg)
#' grid.newpage()
Expand Down Expand Up @@ -493,14 +494,32 @@ decorate_grob_factory <- function(npages, ...) {
#'
#' @examples
#' library(ggplot2)
#' g <- with(iris, {
#' g <- with(data = iris, {
#' list(
#' ggplotGrob(qplot(Sepal.Length, Sepal.Width, col = Species)),
#' ggplotGrob(qplot(Sepal.Length, Petal.Length, col = Species)),
#' ggplotGrob(qplot(Sepal.Length, Petal.Width, col = Species)),
#' ggplotGrob(qplot(Sepal.Width, Petal.Length, col = Species)),
#' ggplotGrob(qplot(Sepal.Width, Petal.Width, col = Species)),
#' ggplotGrob(qplot(Petal.Length, Petal.Width, col = Species))
#' ggplot2::ggplotGrob(
#' ggplot2::ggplot(mapping = aes(Sepal.Length, Sepal.Width, col = Species)) +
#' ggplot2::geom_point()
#' ),
#' ggplot2::ggplotGrob(
#' ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Length, col = Species)) +
#' ggplot2::geom_point()
#' ),
#' ggplot2::ggplotGrob(
#' ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Width, col = Species)) +
#' ggplot2::geom_point()
#' ),
#' ggplot2::ggplotGrob(
#' ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Length, col = Species)) +
#' ggplot2::geom_point()
#' ),
#' ggplot2::ggplotGrob(
#' ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Width, col = Species)) +
#' ggplot2::geom_point()
#' ),
#' ggplot2::ggplotGrob(
#' ggplot2::ggplot(mapping = aes(Petal.Length, Petal.Width, col = Species)) +
#' ggplot2::geom_point()
#' )
#' )
#' })
#' lg <- decorate_grob_set(grobs = g, titles = "Hello\nOne\nTwo\nThree", footnotes = "")
Expand Down
4 changes: 3 additions & 1 deletion R/wrap_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ wrap_text <- function(txt, # nolint
width = grid::convertWidth(grid::unit(1, "npc"), "inch", TRUE),
gp = grid::gpar(),
collapse = NULL) {
warning("This is a deprecated function as there is a current implementation in rtables, not based on grid::")
dep_msg <- "Please use current implementation in rtables, not based on grid::"
lifecycle::deprecate_warn("0.7.10", "wrap_test()", details = dep_msg)

if (grid::is.unit(width)) {
width <- grid::convertWidth(width, "inch", TRUE)
}
Expand Down
3 changes: 2 additions & 1 deletion man/decorate_grob.Rd

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

32 changes: 25 additions & 7 deletions man/decorate_grob_set.Rd

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

32 changes: 25 additions & 7 deletions tests/testthat/test-decorate_grob.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,32 @@ testthat::test_that("decorate_grob_factory returns page warning correctly", {
})

testthat::test_that("decorate_grob_set returns no warnings when creating a non-empty plot", {
g <- with(iris, {
g <- with(data = iris, {
list(
ggplot2::ggplotGrob(ggplot2::qplot(Sepal.Length, Sepal.Width, col = Species)),
ggplot2::ggplotGrob(ggplot2::qplot(Sepal.Length, Petal.Length, col = Species)),
ggplot2::ggplotGrob(ggplot2::qplot(Sepal.Length, Petal.Width, col = Species)),
ggplot2::ggplotGrob(ggplot2::qplot(Sepal.Width, Petal.Length, col = Species)),
ggplot2::ggplotGrob(ggplot2::qplot(Sepal.Width, Petal.Width, col = Species)),
ggplot2::ggplotGrob(ggplot2::qplot(Petal.Length, Petal.Width, col = Species))
ggplot2::ggplotGrob(
ggplot2::ggplot(mapping = aes(Sepal.Length, Sepal.Width, col = Species)) +
ggplot2::geom_point()
),
ggplot2::ggplotGrob(
ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Length, col = Species)) +
ggplot2::geom_point()
),
ggplot2::ggplotGrob(
ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Width, col = Species)) +
ggplot2::geom_point()
),
ggplot2::ggplotGrob(
ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Length, col = Species)) +
ggplot2::geom_point()
),
ggplot2::ggplotGrob(
ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Width, col = Species)) +
ggplot2::geom_point()
),
ggplot2::ggplotGrob(
ggplot2::ggplot(mapping = aes(Petal.Length, Petal.Width, col = Species)) +
ggplot2::geom_point()
)
)
})
lg <- testthat::expect_silent(
Expand Down
42 changes: 21 additions & 21 deletions tests/testthat/test-g_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ testthat::test_that("g_km default plot works", {

variables <- list(tte = "AVAL", is_event = "is_event", arm = "ARMCD")

result <- testthat::expect_silent(
g_km(
df = df,
variables = variables,
ci_ribbon = FALSE,
draw = FALSE
)
grob_tmp <- g_km(
df = df,
variables = variables,
ci_ribbon = FALSE,
draw = FALSE
)

testthat::expect_true(grid::is.grob(grob_tmp))
})

testthat::test_that("g_km default plot witch ci_ribbon = TRUE works", {
Expand All @@ -22,14 +22,14 @@ testthat::test_that("g_km default plot witch ci_ribbon = TRUE works", {

variables <- list(tte = "AVAL", is_event = "is_event", arm = "ARMCD")

result <- testthat::expect_silent(
g_km(
df = df,
variables = variables,
ci_ribbon = TRUE,
draw = FALSE
)
grob_tmp <- g_km(
df = df,
variables = variables,
ci_ribbon = TRUE,
draw = FALSE
)

testthat::expect_true(grid::is.grob(grob_tmp))
})

testthat::test_that("g_km plot with < = > in group labels works", {
Expand All @@ -43,12 +43,12 @@ testthat::test_that("g_km plot with < = > in group labels works", {

variables <- list(tte = "AVAL", is_event = "is_event", arm = "group")

result <- testthat::expect_silent(
g_km(
df = df,
variables = variables,
annot_surv_med = FALSE,
draw = FALSE
)
grob_tmp <- g_km(
df = df,
variables = variables,
annot_surv_med = FALSE,
draw = FALSE
)

testthat::expect_true(grid::is.grob(grob_tmp))
})
4 changes: 3 additions & 1 deletion tests/testthat/test-wrap_text.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
testthat::test_that("wrap_text works with default settings", {
text <- "This is a test with many words and more"
result <- wrap_text(txt = text, width = grid::unit(4, "cm"), collapse = "\n")
result <- testthat::expect_warning(
Melkiades marked this conversation as resolved.
Show resolved Hide resolved
wrap_text(txt = text, width = grid::unit(4, "cm"), collapse = "\n")
)
expected <- "This is a test with\nmany words and\nmore"
testthat::expect_identical(result, expected)
})