From 111d2a8a3edd781f7e272668be9647f87b3db941 Mon Sep 17 00:00:00 2001 From: EuanMcGonigle <51928132+EuanMcGonigle@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:16:37 +0100 Subject: [PATCH] update code styling styler --- R/multilag.cpts.merge.R | 6 +- R/multiscale.np.mojo.R | 16 +- R/np.mojo.R | 3 +- R/np.mojo.multilag.R | 6 +- R/utils.R | 2 +- tests/testthat/test-multilag.R | 22 ++- tests/testthat/test-multiscale.np.mojo.R | 22 ++- tests/testthat/test-np.R | 228 ++++++++++++++--------- tests/testthat/test-np.mojo.R | 28 +-- 9 files changed, 203 insertions(+), 130 deletions(-) diff --git a/R/multilag.cpts.merge.R b/R/multilag.cpts.merge.R index 83407cb..ba7de8e 100644 --- a/R/multilag.cpts.merge.R +++ b/R/multilag.cpts.merge.R @@ -36,8 +36,10 @@ #' x.c #' @seealso \link{np.mojo}, \link{np.mojo.multilag} multilag.cpts.merge <- function(x.c, eta.merge = 1, merge.type = c("sequential", "bottom-up")[1]) { - stopifnot("Error: change point merging type must be either 'sequential' or 'bottom-up'." = - merge.type == "sequential" || merge.type == "bottom-up") + stopifnot( + "Error: change point merging type must be either 'sequential' or 'bottom-up'." = + merge.type == "sequential" || merge.type == "bottom-up" + ) cpts <- init.cpts <- matrix(NA, nrow = 0, ncol = 3) dimnames(init.cpts)[[2]] <- c("cp", "lag", "p.val") diff --git a/R/multiscale.np.mojo.R b/R/multiscale.np.mojo.R index 49de8ca..7062d56 100644 --- a/R/multiscale.np.mojo.R +++ b/R/multiscale.np.mojo.R @@ -100,7 +100,7 @@ #' noise <- c(rep(1, 300), rep(0.4, 200)) * stats::arima.sim(model = list(ar = 0.3), n = n) #' signal <- c(rep(0, 100), rep(2, 400)) #' x <- signal + noise -#' x.c <- multiscale.np.mojo(x, G = c(50,80), lags = c(0, 1)) +#' x.c <- multiscale.np.mojo(x, G = c(50, 80), lags = c(0, 1)) #' x.c$cpts #' @seealso \link{np.mojo.multilag} multiscale.np.mojo <- function(x, G, lags = c(0, 1), kernel.f = c("quad.exp", "gauss", "euclidean", "laplace", "sine")[1], @@ -109,8 +109,10 @@ multiscale.np.mojo <- function(x, G, lags = c(0, 1), kernel.f = c("quad.exp", "g boot.method = c("mean.subtract", "no.mean.subtract")[1], criterion = c("eta", "epsilon", "eta.and.epsilon")[3], eta = 0.4, epsilon = 0.02, use.mean = FALSE, eta.merge = 1, merge.type = c("sequential", "bottom-up")[1], eta.bottom.up = 0.8) { - stopifnot("Error: change point merging type must be either 'sequential' or 'bottom-up'." = - merge.type == "sequential" || merge.type == "bottom-up") + stopifnot( + "Error: change point merging type must be either 'sequential' or 'bottom-up'." = + merge.type == "sequential" || merge.type == "bottom-up" + ) if (!is.numeric(lags)) { stop("The set of lags must be a numeric vector of positive integer values.") @@ -146,10 +148,10 @@ multiscale.np.mojo <- function(x, G, lags = c(0, 1), kernel.f = c("quad.exp", "g cptsInOrder <- seq_len(nrow(init.cpts)) for (i in cptsInOrder) { - p <- init.cpts[i,1] - l <- init.cpts[i,2] - pVal <- init.cpts[i,3] - G.val <- init.cpts[i,4] + p <- init.cpts[i, 1] + l <- init.cpts[i, 2] + pVal <- init.cpts[i, 3] + G.val <- init.cpts[i, 4] if (suppressWarnings(min(abs(p - points))) >= eta.bottom.up * G.val) { points <- c(points, p) bandwidths <- c(bandwidths, G.val) diff --git a/R/np.mojo.R b/R/np.mojo.R index 5c964f8..9e40666 100644 --- a/R/np.mojo.R +++ b/R/np.mojo.R @@ -227,7 +227,7 @@ np.mojo <- function(x, G, lag = 0, kernel.f = c("quad.exp", "gauss", "euclidean" start.r <- end.r - r$lengths + 1 epsilon.satisfied.start <- stat.exceed[start.r[r$lengths > epsilon * G]] - epsilon.satisfied.end <- stat.exceed[end.r[r$lengths > epsilon * G]]+1 + epsilon.satisfied.end <- stat.exceed[end.r[r$lengths > epsilon * G]] + 1 epsilon.exceedings <- rep(FALSE, data.len) for (i in seq_len(length(epsilon.satisfied.start))) { @@ -248,7 +248,6 @@ np.mojo <- function(x, G, lag = 0, kernel.f = c("quad.exp", "gauss", "euclidean" for (i in seq_len(length(cpt.locs))) { p.vals <- c(p.vals, sum(Tstar >= test.stat[cpt.locs[i]]) / (reps + 1)) } - } } else { if (threshold == "bootstrap") { diff --git a/R/np.mojo.multilag.R b/R/np.mojo.multilag.R index dfde0a4..debc5ad 100644 --- a/R/np.mojo.multilag.R +++ b/R/np.mojo.multilag.R @@ -104,8 +104,10 @@ np.mojo.multilag <- function(x, G, lags = c(0, 1), kernel.f = c("quad.exp", "gau alpha = 0.1, reps = 199, boot.dep = 1.5 * (nrow(as.matrix(x))^(1 / 3)), parallel = FALSE, boot.method = c("mean.subtract", "no.mean.subtract")[1], criterion = c("eta", "epsilon", "eta.and.epsilon")[3], eta = 0.4, epsilon = 0.02, use.mean = FALSE, eta.merge = 1, merge.type = c("sequential", "bottom-up")[1]) { - stopifnot("Error: change point merging type must be either 'sequential' or 'bottom-up'." = - merge.type == "sequential" || merge.type == "bottom-up") + stopifnot( + "Error: change point merging type must be either 'sequential' or 'bottom-up'." = + merge.type == "sequential" || merge.type == "bottom-up" + ) if (!is.numeric(lags)) { stop("The set of lags must be a numeric vector of positive integer values.") diff --git a/R/utils.R b/R/utils.R index c3037ba..692d2cd 100644 --- a/R/utils.R +++ b/R/utils.R @@ -133,7 +133,7 @@ mojo.error.checks <- function(x, G, lag, kernel.f, kern.par, data.driven.kern.pa stop("The lag parameter should be a single positive integer.") } - if (!is.numeric(G) || (G < 0) || (G %% 1 != 0) ) { + if (!is.numeric(G) || (G < 0) || (G %% 1 != 0)) { stop("Bandwidth parameter G must be numeric positive integer.") } diff --git a/tests/testthat/test-multilag.R b/tests/testthat/test-multilag.R index 761d1c2..ccaf3fa 100644 --- a/tests/testthat/test-multilag.R +++ b/tests/testthat/test-multilag.R @@ -1,4 +1,4 @@ -#Tests for multilag.cpts.merge function +# Tests for multilag.cpts.merge function n <- 1000 set.seed(123) @@ -15,12 +15,12 @@ x.nocp <- stats:::rnorm(1000) G <- 166 -x.c0 <- np.mojo(x,G,0) -x.c1 <- np.mojo(x,G,1) +x.c0 <- np.mojo(x, G, 0) +x.c1 <- np.mojo(x, G, 1) test_that("multilag.cpts.merge executes with sequential merging", { skip_on_cran() - expect_equal(class(multilag.cpts.merge(x.c = list(x.c0,x.c1), merge.type = "sequential")), "list") + expect_equal(class(multilag.cpts.merge(x.c = list(x.c0, x.c1), merge.type = "sequential")), "list") }) test_that("multilag.cpts.merge executes with bottom-up merging", { @@ -28,14 +28,16 @@ test_that("multilag.cpts.merge executes with bottom-up merging", { expect_equal(class(multilag.cpts.merge(x.c = list(x.c0, x.c1), merge.type = "bottom-up")), "list") }) -test_that("Change point merging type is recognised",{ - expect_error(multilag.cpts.merge(x.c = list(x.c0, x.c1), merge.type = "pruning"), - "Error: change point merging type must be either 'sequential' or 'bottom-up'.") +test_that("Change point merging type is recognised", { + expect_error( + multilag.cpts.merge(x.c = list(x.c0, x.c1), merge.type = "pruning"), + "Error: change point merging type must be either 'sequential' or 'bottom-up'." + ) }) test_that("multilag.cpts.merge executes when no change points", { skip_on_cran() - x.nocp0 <- np.mojo(x.nocp,G,0, threshold = "manual", threshold.val = 5) - x.nocp1 <- np.mojo(x.nocp,G,1, threshold = "manual", threshold.val = 5) - expect_equal(class(multilag.cpts.merge(x.c = list(x.nocp0,x.nocp1), merge.type = "sequential")), "list") + x.nocp0 <- np.mojo(x.nocp, G, 0, threshold = "manual", threshold.val = 5) + x.nocp1 <- np.mojo(x.nocp, G, 1, threshold = "manual", threshold.val = 5) + expect_equal(class(multilag.cpts.merge(x.c = list(x.nocp0, x.nocp1), merge.type = "sequential")), "list") }) diff --git a/tests/testthat/test-multiscale.np.mojo.R b/tests/testthat/test-multiscale.np.mojo.R index db015d3..fad91ec 100644 --- a/tests/testthat/test-multiscale.np.mojo.R +++ b/tests/testthat/test-multiscale.np.mojo.R @@ -3,11 +3,27 @@ test_that("multiscale NP-MOJO executes", { noise <- c(rep(1, 300), rep(0.4, 200)) * stats::rnorm(n) signal <- c(rep(0, 100), rep(2, 400)) x <- signal + noise - x.c <- multiscale.np.mojo(x, G = c(50,80), lags = c(0, 1), reps = 10) + x.c <- multiscale.np.mojo(x, G = c(50, 80), lags = c(0, 1), reps = 10) expect_equal(class(x.c), "list") }) test_that("multiscale NP-MOJO rejects incorrect bandwidths", { - expect_error(multiscale.np.mojo(stats::rnorm(100), G = c(-10,30)), - "Bandwidth parameter G must be numeric positive integer.") + expect_error( + multiscale.np.mojo(stats::rnorm(100), G = c(-10, 30)), + "Bandwidth parameter G must be numeric positive integer." + ) +}) + +test_that("multiscale NP-MOJO rejects non-numeric lags", { + expect_error( + multiscale.np.mojo(stats::rnorm(100), G = c(10, 30), lags = c("1", "2")), + "The set of lags must be a numeric vector of positive integer values." + ) +}) + +test_that("multiscale NP-MOJO rejects negative lags", { + expect_error( + multiscale.np.mojo(stats::rnorm(100), G = c(10, 30), lags = c(-1, 0, 3)), + "The set of lags must be a numeric vector of positive integer values." + ) }) diff --git a/tests/testthat/test-np.R b/tests/testthat/test-np.R index fb77f4f..1d0a00a 100644 --- a/tests/testthat/test-np.R +++ b/tests/testthat/test-np.R @@ -1,181 +1,225 @@ -#Tests for np.mojo function +# Tests for np.mojo function set.seed(1) -x <- stats::rnorm(500)+c(rep(0,200),rep(2,300)) +x <- stats::rnorm(500) + c(rep(0, 200), rep(2, 300)) G <- 80 -kernels <- c('quad.exp', 'gauss', 'laplace', 'sine', 'euclidean') -criteria <- c('eta', 'epsilon', 'eta.and.epsilon') +kernels <- c("quad.exp", "gauss", "laplace", "sine", "euclidean") +criteria <- c("eta", "epsilon", "eta.and.epsilon") -for(i in seq_len(length(kernels))){ - test_that(paste0('np.mojo with Kernel #',i, " executes with data.driven.par FALSE"), { +for (i in seq_len(length(kernels))) { + test_that(paste0("np.mojo with Kernel #", i, " executes with data.driven.par FALSE"), { skip_on_cran() - expect_equal(class(np.mojo(x,G, kernel.f = kernels[i], data.driven.kern.par = FALSE)), "list") + expect_equal(class(np.mojo(x, G, kernel.f = kernels[i], data.driven.kern.par = FALSE)), "list") }) } -for(i in (seq_len(length(kernels)-1))){ - test_that(paste0('np.mojo with Kernel #',i, " executes with data.driven.par TRUE"), { +for (i in (seq_len(length(kernels) - 1))) { + test_that(paste0("np.mojo with Kernel #", i, " executes with data.driven.par TRUE"), { skip_on_cran() - expect_equal(class(np.mojo(x,G, kernel.f = kernels[i], data.driven.kern.par = TRUE)), "list") + expect_equal(class(np.mojo(x, G, kernel.f = kernels[i], data.driven.kern.par = TRUE)), "list") }) } -for(i in seq_len(length(criteria))){ - test_that(paste0('np.mojo with criteria #',i, " executes"), { +for (i in seq_len(length(criteria))) { + test_that(paste0("np.mojo with criteria #", i, " executes"), { skip_on_cran() - expect_equal(class(np.mojo(x,G, criterion = criteria[i])), "list") + expect_equal(class(np.mojo(x, G, criterion = criteria[i])), "list") }) } test_that("np.mojo executes with param 'boot.method' = 'no.mean.subtract'", { skip_on_cran() - expect_equal(class(np.mojo(x,G, boot.method = "no.mean.subtract")), "list") + expect_equal(class(np.mojo(x, G, boot.method = "no.mean.subtract")), "list") }) test_that("np.mojo executes with default params", { skip_on_cran() - expect_equal(class(np.mojo(x,G)), "list") + expect_equal(class(np.mojo(x, G)), "list") }) test_that("np.mojo executes with parallel", { - skip_on_cran() - expect_equal(class(np.mojo(x,G, parallel = TRUE)), "list") - }) + skip_on_cran() + expect_equal(class(np.mojo(x, G, parallel = TRUE)), "list") +}) test_that("np.mojo executes with use.mean", { skip_on_cran() - expect_equal(class(np.mojo(x,G, use.mean = TRUE)), "list") + expect_equal(class(np.mojo(x, G, use.mean = TRUE)), "list") }) test_that("np.mojo executes with matrix data", { skip_on_cran() X <- matrix(stats::rnorm(1000), ncol = 2, nrow = 500) - expect_equal(class(np.mojo(X,G)), "list") + expect_equal(class(np.mojo(X, G)), "list") }) -test_that("Criterion choice is recognised",{ - expect_error(np.mojo(x = x, G = G, criterion = "eat"), - "Error: change point detection criterion must be one of 'eta', 'epsilon', or 'eta.and.epsilon'.") +test_that("Criterion choice is recognised", { + expect_error( + np.mojo(x = x, G = G, criterion = "eat"), + "Error: change point detection criterion must be one of 'eta', 'epsilon', or 'eta.and.epsilon'." + ) }) -test_that("Kernel.f choice is recognised",{ - expect_error(np.mojo(x = x, G = G, kernel.f = "normal"), - "The kernel.f function must be either 'quad.exp', 'gauss', 'laplace', 'sine', or 'euclidean'") +test_that("Kernel.f choice is recognised", { + expect_error( + np.mojo(x = x, G = G, kernel.f = "normal"), + "The kernel.f function must be either 'quad.exp', 'gauss', 'laplace', 'sine', or 'euclidean'" + ) }) -test_that("boot.method choice is recognised",{ - expect_error(np.mojo(x = x, G = G, boot.method = "multiplier"), - "Parameter 'boot.method' must be set to be either 'mean.subtract' or 'no.mean.subtract'. Highly - recommended to set boot.method = 'mean.subtract'.") +test_that("boot.method choice is recognised", { + expect_error( + np.mojo(x = x, G = G, boot.method = "multiplier"), + "Parameter 'boot.method' must be set to be either 'mean.subtract' or 'no.mean.subtract'. Highly + recommended to set boot.method = 'mean.subtract'." + ) }) -test_that("parallel argument is logical",{ - expect_error(np.mojo(x = x, G = G, parallel = "true"), - "Error: 'parallel' argument must be logical variable.") +test_that("parallel argument is logical", { + expect_error( + np.mojo(x = x, G = G, parallel = "true"), + "Error: 'parallel' argument must be logical variable." + ) }) -test_that("use.mean argument is logical",{ - expect_error(np.mojo(x = x, G = G, use.mean = "true"), - "Error: 'use.mean' argument must be logical variable.") +test_that("use.mean argument is logical", { + expect_error( + np.mojo(x = x, G = G, use.mean = "true"), + "Error: 'use.mean' argument must be logical variable." + ) }) -test_that("data.driven.kern.par argument is logical",{ - expect_error(np.mojo(x = x, G = G, data.driven.kern.par = "true"), - "Error: 'data.driven.kern.par' argument must be logical variable.") +test_that("data.driven.kern.par argument is logical", { + expect_error( + np.mojo(x = x, G = G, data.driven.kern.par = "true"), + "Error: 'data.driven.kern.par' argument must be logical variable." + ) }) -test_that("boot.dep argument is positive",{ - expect_error(np.mojo(x = x, G = G, boot.dep = -2), - "The bootstrap dependence parameter 'boot.dep' must be a positive value.") +test_that("boot.dep argument is positive", { + expect_error( + np.mojo(x = x, G = G, boot.dep = -2), + "The bootstrap dependence parameter 'boot.dep' must be a positive value." + ) }) -test_that("kern.par argument is positive",{ - expect_error(np.mojo(x = x, G = G, kern.par = -2), - "The kernel parameter must be a positive value.") +test_that("kern.par argument is positive", { + expect_error( + np.mojo(x = x, G = G, kern.par = -2), + "The kernel parameter must be a positive value." + ) }) -test_that("reps argument is positive",{ - expect_error(np.mojo(x = x, G = G, reps = -2), - "Number of bootstrap replications should be a single positive integer.") +test_that("reps argument is positive", { + expect_error( + np.mojo(x = x, G = G, reps = -2), + "Number of bootstrap replications should be a single positive integer." + ) }) -test_that("reps argument is numeric",{ - expect_error(np.mojo(x = x, G = G, reps = "2"), - "Number of bootstrap replications should be a single positive integer.") +test_that("reps argument is numeric", { + expect_error( + np.mojo(x = x, G = G, reps = "2"), + "Number of bootstrap replications should be a single positive integer." + ) }) -test_that("lag argument is positive",{ - expect_error(np.mojo(x = x, G = G, lag = -1), - "The lag parameter should be a single positive integer.") +test_that("lag argument is positive", { + expect_error( + np.mojo(x = x, G = G, lag = -1), + "The lag parameter should be a single positive integer." + ) }) -test_that("lag argument is numeric",{ - expect_error(np.mojo(x = x, G = G, lag = "1"), - "The lag parameter should be a single positive integer.") +test_that("lag argument is numeric", { + expect_error( + np.mojo(x = x, G = G, lag = "1"), + "The lag parameter should be a single positive integer." + ) }) -test_that("G is numeric",{ - expect_error(np.mojo(x = x, G = "100"), - "Bandwidth parameter G must be numeric positive integer.") +test_that("G is numeric", { + expect_error( + np.mojo(x = x, G = "100"), + "Bandwidth parameter G must be numeric positive integer." + ) }) -test_that("G is larger than lag",{ - expect_error(np.mojo(x = x, G = 20, lag = 25), - "Bandwidth parameter G must be larger than the chosen lag.") +test_that("G is larger than lag", { + expect_error( + np.mojo(x = x, G = 20, lag = 25), + "Bandwidth parameter G must be larger than the chosen lag." + ) }) -test_that("x has no NAs",{ - expect_error(np.mojo(x = c(x[1:499],NA), G = G), - "Missing values in data: NA is not allowed in the data.") +test_that("x has no NAs", { + expect_error( + np.mojo(x = c(x[1:499], NA), G = G), + "Missing values in data: NA is not allowed in the data." + ) }) -test_that("x is numeric",{ - expect_error(np.mojo(x = rep("1",500), G = G), - "Data must be numeric.") +test_that("x is numeric", { + expect_error( + np.mojo(x = rep("1", 500), G = G), + "Data must be numeric." + ) }) -test_that("threshold is recognised",{ - expect_error(np.mojo(x = x, G = G, threshold = "asymptotic"), - "Threshold type parameter 'threshold' must be set to be either 'bootstrap' or 'manual'.") +test_that("threshold is recognised", { + expect_error( + np.mojo(x = x, G = G, threshold = "asymptotic"), + "Threshold type parameter 'threshold' must be set to be either 'bootstrap' or 'manual'." + ) }) -test_that("threshold type 'manual' has threshold.val set",{ - expect_error(np.mojo(x = x, G = G, threshold = "manual"), - "Threshold type has been set to 'manual', but threshold.val has not been set.") +test_that("threshold type 'manual' has threshold.val set", { + expect_error( + np.mojo(x = x, G = G, threshold = "manual"), + "Threshold type has been set to 'manual', but threshold.val has not been set." + ) }) -test_that("threshold type 'manual' has positive numeric threshold.val",{ - expect_error(np.mojo(x = x, G = G, threshold = "manual", threshold.val = -0.05), - "Parameter threshold.val must be a nonnegative number.") +test_that("threshold type 'manual' has positive numeric threshold.val", { + expect_error( + np.mojo(x = x, G = G, threshold = "manual", threshold.val = -0.05), + "Parameter threshold.val must be a nonnegative number." + ) }) -test_that("reps only used with threshold = 'bootstrap",{ +test_that("reps only used with threshold = 'bootstrap", { skip_on_cran() - expect_warning(np.mojo(x = x, G = G, threshold = "manual", threshold.val = 0.1, reps = 200), - "reps is only used with threshold=bootstrap") + expect_warning( + np.mojo(x = x, G = G, threshold = "manual", threshold.val = 0.1, reps = 200), + "reps is only used with threshold=bootstrap" + ) }) -test_that("Euclidean kernel has appropriate kern.par value",{ - expect_error(np.mojo(x = x, G = G, kernel.f = "euclidean", kern.par = 10, data.driven.kern.par = FALSE), - "For the 'euclidean' kernel, the kernel parameter must be in the interval (0,2).", - fixed = TRUE) +test_that("Euclidean kernel has appropriate kern.par value", { + expect_error(np.mojo(x = x, G = G, kernel.f = "euclidean", kern.par = 10, data.driven.kern.par = FALSE), + "For the 'euclidean' kernel, the kernel parameter must be in the interval (0,2).", + fixed = TRUE + ) }) -test_that("warning when Euclidean kernel used with data.driven.par = TRUE",{ - expect_warning(np.mojo(x = x, G = G, kernel.f = "euclidean", data.driven.kern.par = TRUE), - "Data driven parameter choice not suited for Euclidean kernel. Parameter kern.par reset to 1.") +test_that("warning when Euclidean kernel used with data.driven.par = TRUE", { + expect_warning( + np.mojo(x = x, G = G, kernel.f = "euclidean", data.driven.kern.par = TRUE), + "Data driven parameter choice not suited for Euclidean kernel. Parameter kern.par reset to 1." + ) }) -test_that("G is not too large",{ - expect_error(np.mojo(x = x, G = 400), - "Bandwidth is too large for the length of time series.") +test_that("G is not too large", { + expect_error( + np.mojo(x = x, G = 400), + "Bandwidth is too large for the length of time series." + ) }) - diff --git a/tests/testthat/test-np.mojo.R b/tests/testthat/test-np.mojo.R index e72e8e3..205be38 100644 --- a/tests/testthat/test-np.mojo.R +++ b/tests/testthat/test-np.mojo.R @@ -1,7 +1,7 @@ -#Tests for np.mojo.multilag function +# Tests for np.mojo.multilag function set.seed(1) -x <- rnorm(500)+c(rep(0,200),rep(2,300)) +x <- rnorm(500) + c(rep(0, 200), rep(2, 300)) G <- 80 x.c <- np.mojo.multilag(x, G = G) @@ -11,17 +11,23 @@ test_that("np.mojo.multilag executes", { expect_equal(class(x.c), "list") }) -test_that("Change point merging type is recognised",{ - expect_error(np.mojo.multilag(x, G = G, merge.type = "pruning"), - "Error: change point merging type must be either 'sequential' or 'bottom-up'.") +test_that("Change point merging type is recognised", { + expect_error( + np.mojo.multilag(x, G = G, merge.type = "pruning"), + "Error: change point merging type must be either 'sequential' or 'bottom-up'." + ) }) -test_that("lags parameter is numeric",{ - expect_error(np.mojo.multilag(x, G = G, lags = c("0", "1")), - "The set of lags must be a numeric vector of positive integer values.") +test_that("lags parameter is numeric", { + expect_error( + np.mojo.multilag(x, G = G, lags = c("0", "1")), + "The set of lags must be a numeric vector of positive integer values." + ) }) -test_that("lags parameter contains positive values",{ - expect_error(np.mojo.multilag(x, G = G, lags = c(0,-1)), - "The set of lags must be a numeric vector of positive integer values.") +test_that("lags parameter contains positive values", { + expect_error( + np.mojo.multilag(x, G = G, lags = c(0, -1)), + "The set of lags must be a numeric vector of positive integer values." + ) })