Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Nov 7, 2024
1 parent e191485 commit 0880c49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions tests/testthat/test-convert-log-scale.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("Can convert to and from log scale in R", {
inputs <- data.table::fread(test_path("testdata", "testdata.csv"))
log_inputs <- convert_log2_scale(inputs, "me", lower_detection_limit = 2)
unlog_inputs <- convert_log2_scale_inverse(log_inputs, "me", lower_detection_limit = 2)
log_inputs <- convert_log2_scale(inputs, "me", smallest_value = 2)
unlog_inputs <- convert_log2_scale_inverse(log_inputs, "me", smallest_value = 2)

expect_equal(inputs, unlog_inputs)
})
Expand All @@ -11,7 +11,7 @@ test_that("Can convert from log scale in R", {
res <- convert_log2_scale_inverse(
inputs,
vars_to_transform = c("me", "lo"),
lower_detection_limit = 5)
smallest_value = 5)

expect_equal(res$me, 5 * 2^inputs$me)
expect_equal(res$lo, 5 * 2^inputs$lo)
Expand All @@ -22,7 +22,7 @@ test_that("Can convert from log scale in R", {
res <- convert_log2_scale_inverse(
inputs,
vars_to_transform = "me",
lower_detection_limit = 10)
smallest_value = 10)

expect_equal(res$me, 10 * 2^inputs$me)
})
Expand All @@ -32,7 +32,7 @@ test_that("Can convert from log scale in Cpp", {
rescpp <- convert_log2_scale_inverse_cpp(
inputs,
vars_to_transform = c("me", "lo"),
lower_detection_limit = 5)
smallest_value = 5)

expect_equal(rescpp$me, 5 * 2^(inputs$me))
expect_equal(rescpp$lo, 5 * 2^(inputs$lo))
Expand All @@ -43,7 +43,7 @@ test_that("Can convert from log scale in Cpp", {
res <- convert_log2_scale_inverse_cpp(
inputs,
vars_to_transform = "me",
lower_detection_limit = 10)
smallest_value = 10)

expect_equal(res$me, 10 * 2^inputs$me)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test_that("Can plot prior predictions from model", {
set.seed(1)
plot <- mod$plot_prior_predictive(tmax = 400, n_draws = 500)
expect_equal(nrow(plot$data), 400)
expect_equal(length(plot$layers), 3)
expect_equal(length(plot$layers), 7) # includes detection limits
})

test_that("Prior predictions from model are the same", {
Expand Down

0 comments on commit 0880c49

Please sign in to comment.