Skip to content

Commit

Permalink
Update Poisson example
Browse files Browse the repository at this point in the history
  • Loading branch information
doccstat committed Dec 20, 2023
1 parent f9b6930 commit 836118a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ vignettes/*.aux
.vscode/
docs
pkgdown/favicon/
CRAN-SUBMISSION
2 changes: 1 addition & 1 deletion R/fastcpd_wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ fastcpd_mv <- fastcpd.meanvariance
#' except that the data is by default a matrix or data frame with the response
#' variable as the first column and thus a formula is not required here.
#'
#' @example tests/testthat/examples/fastcpd_poisson.R
#' @example tests/testthat/examples/fastcpd_poisson.txt
#'
#' @md
#'
Expand Down
2 changes: 2 additions & 0 deletions man/fastcpd_poisson.Rd

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

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
\donttest{
set.seed(1)
n <- 1100
p <- 3
Expand All @@ -13,3 +14,4 @@ y <- c(
result <- fastcpd.poisson(cbind(y, x))
summary(result)
plot(result)
}
10 changes: 8 additions & 2 deletions tests/testthat/test-examples-fastcpd_poisson.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
testthat::test_that(
"examples/fastcpd_poisson.R", {
"examples/fastcpd_poisson.txt", {
testthat::skip_if_not_installed("mvtnorm")
source("examples/fastcpd_poisson.R")

examples_poisson <- readLines("examples/fastcpd_poisson.txt")
source(textConnection(paste(
examples_poisson[seq_len(length(examples_poisson) - 2) + 1],
collapse = "\n"
)))

testthat::expect_equal(result@cp_set, c(498, 800, 1003))
}
)

0 comments on commit 836118a

Please sign in to comment.