From e0435d6532bd82352368341ab550e3a0c4ea18c3 Mon Sep 17 00:00:00 2001 From: Joshua Ulrich Date: Tue, 29 Aug 2023 16:42:39 -0500 Subject: [PATCH] Fix plot unit tests One unit test uses get_xlim(), which was removed earlier because it's not used internally. get_ylim() no longer returns a list, so there's no need to subset. --- R/plot.R | 2 ++ inst/tinytest/test-plot.R | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/R/plot.R b/R/plot.R index 69dc0b92..4e6d0d67 100644 --- a/R/plot.R +++ b/R/plot.R @@ -929,6 +929,7 @@ new.replot_xts <- function(panel=1,asp=1,xlim=c(1,10),ylim=list(structure(c(1,10 # getters get_panel <- function(n) { if (n == 0) get_last_action_panel() else Env$panels[[n]] } get_ylim <- function() { update_panels(); get_active_panel()[["ylim_render"]] } + get_xlim <- function() { update_panels(); Env$xlim } get_active_panel <- function() { get_panel(Env$active_panel_i) } get_last_action_panel <- function() { get_panel(Env$last_action_panel_id) } @@ -1385,6 +1386,7 @@ new.replot_xts <- function(panel=1,asp=1,xlim=c(1,10),ylim=list(structure(c(1,10 replot_env$update_panels <- update_panels replot_env$render_panels <- render_panels replot_env$get_panel <- get_panel + replot_env$get_xlim <- get_xlim replot_env$get_ylim <- get_ylim replot_env$create_ylim <- create_ylim replot_env$get_last_action_panel <- get_last_action_panel diff --git a/inst/tinytest/test-plot.R b/inst/tinytest/test-plot.R index 75640d13..8a64c18f 100644 --- a/inst/tinytest/test-plot.R +++ b/inst/tinytest/test-plot.R @@ -35,7 +35,7 @@ expect_equivalent(target, p$get_xlim(), info = info_msg) info_msg <- "test.ylim_set_before_rendering" x <- rnorm(10) p <- plot(xts(x, .Date(1:10))) -expect_equivalent(range(x), p$get_ylim()[[2]], info = info_msg) +expect_equivalent(range(x), p$get_ylim(), info = info_msg) info_msg <- "test.yaxis.ticks" x <- xts(rnorm(50), .Date(1:50))