Skip to content

Commit

Permalink
silencing summary calls in plotting methods to comply with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarneche committed Sep 22, 2023
1 parent 463be23 commit b6a7f14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 12 additions & 4 deletions R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ autoplot.bayesnecfit <- function(object, ..., nec = TRUE, ecx = FALSE,
if (!inherits(xform, "function")) {
stop("xform must be a function.")
}
summ <- summary(x, ecx = FALSE)
summ <- summary(x, ecx = FALSE) |>
suppressWarnings() |>
suppressMessages()
ggbnec_data(x, add_nec = nec, add_ecx = ecx,
xform = xform, ...) |>
mutate(model = x$model, tag = rownames(.env$summ$nec_vals)) |>
Expand Down Expand Up @@ -112,7 +114,9 @@ autoplot.bayesmanecfit <- function(object, ..., nec = TRUE, ecx = FALSE,
if (multi_facet) {
names(all_fits) <- x$success_models
nec_labs <- map_dfr(all_fits, function(x) {
summ <- summary(x, ecx = FALSE)
summ <- summary(x, ecx = FALSE) |>
suppressWarnings() |>
suppressMessages()
summ$nec_vals |>
data.frame() |>
rownames_to_column(var = "tag")
Expand All @@ -129,7 +133,9 @@ autoplot.bayesmanecfit <- function(object, ..., nec = TRUE, ecx = FALSE,
}
plots <- vector(mode = "list", length = length(all_fits))
for (i in seq_along(all_fits)) {
summ_i <- summary(all_fits[[i]], ecx = FALSE)
summ_i <- summary(all_fits[[i]], ecx = FALSE) |>
suppressWarnings() |>
suppressMessages()
plots[[i]] <- ggbnec_data(all_fits[[i]], add_nec = nec, add_ecx = ecx,
xform = xform, ...) |>
mutate(model = x$success_models[i],
Expand All @@ -143,7 +149,9 @@ autoplot.bayesmanecfit <- function(object, ..., nec = TRUE, ecx = FALSE,
invisible(plots)
}
} else {
summ <- summary(x, ecx = FALSE)
summ <- summary(x, ecx = FALSE) |>
suppressWarnings() |>
suppressMessages()
ggbnec_data(x, add_nec = nec, add_ecx = ecx, xform = xform, ...) |>
mutate(model = "Model averaged predictions",
tag = rownames(.env$summ$nec_vals)) |>
Expand Down
8 changes: 6 additions & 2 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ plot.bayesnecfit <- function(x, ..., CI = TRUE, add_nec = TRUE,
col = adjustcolor(1, alpha.f = 0.25), ...)
nec_tag <- summary(x, ecx = FALSE) |>
(`[[`)("nec_vals") |>
rownames()
rownames() |>
suppressWarnings() |>
suppressMessages()
if (!inherits(lxform, "function")) {
if (length(xticks) == 1) {
axis(side = 1)
Expand Down Expand Up @@ -289,7 +291,9 @@ plot.bayesmanecfit <- function(x, ..., CI = TRUE, add_nec = TRUE,
col = adjustcolor(1, alpha.f = 0.25), ...)
nec_tag <- summary(x, ecx = FALSE) |>
(`[[`)("nec_vals") |>
rownames()
rownames() |>
suppressWarnings() |>
suppressMessages()
if (!inherits(lxform, "function")) {
if (length(xticks) == 1) {
axis(side = 1)
Expand Down

0 comments on commit b6a7f14

Please sign in to comment.