Skip to content

Commit

Permalink
Temporarily disable warning inside plot()
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjie2wang committed Sep 3, 2024
1 parent a48061c commit f43eee0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ plot.splines2 <- function(x, y, from = NULL, to = NULL, n = 101, coef = NULL,
default_args <- list(type = "l", xlab = "x", ylab = "")
call_args <- modify_list(default_args, dots)
call_args$x <- x_seq
## temporarily disable unnecessary warning messages
old_op <- options("splines2.warn.outside")
on.exit(options(old_op))
options("splines2.warn.outside" = FALSE)
call_args$y <- predict(x, newx = x_seq, coef = coef)
do.call(graphics::matplot, call_args)
mark_knots <- match.arg(mark_knots,
Expand Down
6 changes: 6 additions & 0 deletions inst/tinytest/test-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ plot(res, mark_knots = "none") # current default
plot(res, mark_knots = "internal")
plot(res, mark_knots = "boundary")
plot(res, mark_knots = "all")

## test warning messages
x <- seq.int(- 1, 2, by = 0.1)
bs0 <- bsp(x, degree = 0, knots = 0.4, Boundary.knots = c(0, 1),
intercept = TRUE)
expect_silent(plot(bs0))

0 comments on commit f43eee0

Please sign in to comment.