diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-02-27 12:04:52 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-02-27 12:04:52 +0100 |
commit | 6b4ab746e5474dfeda9237f01bc2dd01f1bb62ee (patch) | |
tree | 7299e1fa4fa9bd0090a5878df985312f528615f4 /tests/testthat/test_plots_summary_twa.R | |
parent | c446b59e675aeff08ff7205b05f06cd81bf6dc68 (diff) |
Increase test coverage
Diffstat (limited to 'tests/testthat/test_plots_summary_twa.R')
-rw-r--r-- | tests/testthat/test_plots_summary_twa.R | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/tests/testthat/test_plots_summary_twa.R b/tests/testthat/test_plots_summary_twa.R index e13111bb..f58ce764 100644 --- a/tests/testthat/test_plots_summary_twa.R +++ b/tests/testthat/test_plots_summary_twa.R @@ -28,23 +28,22 @@ test_that("Time weighted average concentrations are correct", { outtimes_10 <- seq(0, 10, length.out = 10000) - for (ds in c("FOCUS_C", "FOCUS_D")) { - for (model in models) { - fit <- fits[[model, ds]] - bpar <- summary(fit)$bpar[, "Estimate"] - pred_10 <- mkinpredict(fit$mkinmod, - odeparms = bpar[2:length(bpar)], - odeini = c(parent = bpar[[1]]), - outtimes = outtimes_10) - twa_num <- mean(pred_10$parent) - names(twa_num) <- 10 - twa_ana <- max_twa_parent(fit, 10) - - # Test for absolute difference (scale = 1) - # The tolerance can be reduced if the length of outtimes is increased, - # but this needs more computing time so we stay with lenght.out = 10k - expect_equal(twa_num, twa_ana, tolerance = 0.003, scale = 1) - } + ds <- "FOCUS_C" + for (model in models) { + fit <- fits[[model, ds]] + bpar <- summary(fit)$bpar[, "Estimate"] + pred_10 <- mkinpredict(fit$mkinmod, + odeparms = bpar[2:length(bpar)], + odeini = c(parent = bpar[[1]]), + outtimes = outtimes_10) + twa_num <- mean(pred_10$parent) + names(twa_num) <- 10 + twa_ana <- max_twa_parent(fit, 10) + + # Test for absolute difference (scale = 1) + # The tolerance can be reduced if the length of outtimes is increased, + # but this needs more computing time so we stay with lenght.out = 10k + expect_equal(twa_num, twa_ana, tolerance = 0.003, scale = 1) } }) |