Skip to content

Commit 99c41c5

Browse files
author
Nicholas Clark
committed
moar tests
1 parent 8f06040 commit 99c41c5

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

tests/testthat/test-binomial.R

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ test_that("binomial() post-processing works", {
127127
realisations = TRUE, trend_effects = TRUE))
128128
expect_no_error(plot(mod, type = 'smooths',
129129
residuals = TRUE, trend_effects = TRUE))
130+
expect_no_error(plot(mod, type = 're',
131+
trend_effects = TRUE))
130132
expect_no_error(plot(mod, type = 'pterms'))
131133

132134
expect_true(inherits(SM(conditional_effects(mod)),
@@ -307,6 +309,7 @@ test_that("bernoulli() post-processing works", {
307309
expect_true(inherits(hindcast(mod), 'mvgam_forecast'))
308310
expect_true(inherits(hindcast(mod, type = 'expected'), 'mvgam_forecast'))
309311

312+
expect_no_error(plot(mod, type = 're'))
310313
expect_no_error(plot(mod, type = 'smooths'))
311314
expect_no_error(plot(mod, type = 'smooths',
312315
realisations = TRUE))

tests/testthat/test-mvgam-methods.R

+43
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,49 @@ test_that("hindcast has reasonable outputs", {
197197
which(mvgam:::mvgam_example2$obs_data$series == 'series_1')])
198198
})
199199

200+
test_that("plot_mvgam_series reasonable outputs", {
201+
simdat <- sim_mvgam()
202+
expect_no_error(plot_mvgam_series(data = simdat$data_train,
203+
newdata = simdat$data_test))
204+
expect_no_error(plot_mvgam_series(data = simdat$data_train,
205+
newdata = simdat$data_test,
206+
series = 'all'))
207+
expect_no_error(plot_mvgam_series(data = simdat$data_train,
208+
newdata = simdat$data_test,
209+
lines = FALSE))
210+
expect_no_error(plot_mvgam_series(data = simdat$data_train,
211+
newdata = simdat$data_test,
212+
lines = FALSE,
213+
series = 'all'))
214+
215+
# Should also work for list data
216+
dat_train <- list()
217+
for(i in 1:NCOL(simdat$data_train)){
218+
dat_train[[i]] <- simdat$data_train[,i]
219+
}
220+
names(dat_train) <- colnames(simdat$data_train)
221+
222+
dat_test <- list()
223+
for(i in 1:NCOL(simdat$data_test)){
224+
dat_test[[i]] <- simdat$data_test[,i]
225+
}
226+
names(dat_test) <- colnames(simdat$data_test)
227+
228+
expect_no_error(plot_mvgam_series(data = dat_train))
229+
expect_no_error(plot_mvgam_series(data = dat_train,
230+
newdata = dat_test))
231+
expect_no_error(plot_mvgam_series(data = dat_train,
232+
newdata = dat_test,
233+
series = 'all'))
234+
expect_no_error(plot_mvgam_series(data = dat_train,
235+
newdata = dat_test,
236+
lines = FALSE))
237+
expect_no_error(plot_mvgam_series(data = dat_train,
238+
newdata = dat_test,
239+
lines = FALSE,
240+
series = 'all'))
241+
})
242+
200243
test_that("forecast has reasonable outputs", {
201244
skip_on_cran()
202245
set.seed(1234)

tests/testthat/test-mvgam.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ test_that("outcome variable must be present in data", {
188188
'variable y not found in data')
189189
})
190190

191-
test_that("time not requried in data if this is a no trend model", {
191+
test_that("time not required in data if this is a no trend model", {
192192
data = data.frame(out = rnorm(100),
193193
temp = rnorm(100))
194194
mod <- mvgam(formula = out ~ dynamic(temp, rho = 20),

0 commit comments

Comments
 (0)