Skip to content

Commit 3705af0

Browse files
committed
Add tests.
1 parent 6e2239f commit 3705af0

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/testthat.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(testthat)
2+
library(mbr)
3+
4+
test_check("mbr")

tests/testthat/test-p1.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
context("P1")
2+
3+
fit <- mb_reconstruction(p1Seasonal, pc3seasons, 1750, log.trans = 1:3)
4+
set.seed(24)
5+
cvFolds <- make_Z(1922:2003, nRuns = 50, frac = 0.25, contiguous = TRUE)
6+
cv <- cv_mb(p1Seasonal, pc3seasons, cvFolds, 1750, log.trans = 1:3, return.type = 'metrics')
7+
8+
test_that("P.1 reconstruction produces data.table output", {
9+
expect_is(fit, 'data.table')
10+
})
11+
12+
test_that("P.1 reconstruction is numerically correct", {
13+
expect_equal(fit$Q[1], 596.9214, tolerance = 1e-4)
14+
})
15+
16+
test_that("P.1 cross-validation produces data.table output", {
17+
expect_is(cv, 'data.table')
18+
})
19+
20+
test_that("P.1 cross-validation is numerically correct", {
21+
expect_equal(cv$R2[1], 0.4111, tolerance = 1e-4)
22+
})

0 commit comments

Comments
 (0)