Skip to content

Commit

Permalink
add a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Clark committed Nov 1, 2024
1 parent 4fb8c6b commit f18a75c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
^tests/testthat/Rplots\.pdf$
^tests/local$
^memcheck\.R$
^\.gcda$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Meta
/Meta/
desktop.ini
^cran-comments\.md$
^\.gcda$
4 changes: 4 additions & 0 deletions man/jsdgam.Rd

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

2 changes: 0 additions & 2 deletions man/mvgam_marginaleffects.Rd

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

Binary file added src/RcppExports.gcda
Binary file not shown.
Binary file added src/trend_funs.gcda
Binary file not shown.
17 changes: 16 additions & 1 deletion tests/testthat/test-jsdgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,22 @@ test_that("unit must be a numeric / integer in data", {
'Variable "site" must be either numeric or integer type')
})

test_that("n_lv must be <= number of subgroups", {
expect_error(jsdgam(formula = abundance ~
# Environmental model includes species-level interecepts
# and random slopes for a linear effect of reflection
s(taxon, bs = 're') +
s(taxon, bs = 're', by = reflection),
# Each factor estimates a different, possibly nonlinear effect of soil.dry
factor_formula = ~ s(soil.dry, k = 5, by = trend) - 1,
data = spiderdat,
unit = site,
subgr = taxon,
n_lv = 15,
family = nb()),
'Number of factors must be <= number of levels in subgr')
})

test_that("knots must be a list", {
expect_error(jsdgam(formula = abundance ~
# Environmental model includes species-level interecepts
Expand All @@ -429,7 +445,6 @@ test_that("knots must be a list", {
family = nb(),
run_model = FALSE),
'all "knot" arguments must be supplied as lists')

})

test_that("errors about knot lengths should be propagated from mgcv", {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-nmixture.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ test_that("nmix() post-processing works", {
silent = 2))

expect_no_error(capture_output(summary(mod)))
expect_no_error(capture_output(plot(mod, type = 'pterms')))
expect_no_error(capture_output(plot(mod, type = 'pterms', trend_effects = TRUE)))
expect_no_error(capture_output(print(mod)))
expect_true(inherits(hindcast(mod), 'mvgam_forecast'))
expect_true(inherits(hindcast(mod,
Expand Down

0 comments on commit f18a75c

Please sign in to comment.