From 396a92a9c856be554d785daffd8a34b9b26b8640 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 9 Dec 2020 14:32:40 +0100 Subject: Any yet more tests --- test.log | 33 +++++++++++++++++++-------------- tests/testthat/print_mmkin_parent.txt | 13 +++++++++++++ tests/testthat/setup_script.R | 2 +- tests/testthat/test_error_models.R | 1 - tests/testthat/test_mixed.R | 4 +++- 5 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 tests/testthat/print_mmkin_parent.txt diff --git a/test.log b/test.log index 49a1a704..ddc2bc62 100644 --- a/test.log +++ b/test.log @@ -3,35 +3,40 @@ Loading required package: parallel Testing mkin ✔ | OK F W S | Context ✔ | 5 | AIC calculation -✔ | 2 | Export dataset for reading into CAKE [0.2 s] -✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [1.0 s] +✔ | 2 | Export dataset for reading into CAKE +✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [1.1 s] ✔ | 4 | Calculation of FOCUS chi2 error levels [0.5 s] -✔ | 7 | Fitting the SFORB model [3.5 s] -✔ | 5 | Analytical solutions for coupled models [3.2 s] +✔ | 7 | Fitting the SFORB model [3.6 s] +✔ | 5 | Analytical solutions for coupled models [3.3 s] ✔ | 5 | Calculation of Akaike weights ✔ | 14 | Confidence intervals and p-values [1.2 s] -✔ | 14 | Error model fitting [4.6 s] +✔ | 14 | Error model fitting [4.7 s] ✔ | 1 | Time step normalisation ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3 s] ✔ | 1 | Fitting the logistic model [0.2 s] +✔ | 23 | Nonlinear mixed effects models [8.0 s] ✔ | 1 | Test dataset class mkinds used in gmkin ✔ | 1 | mkinfit features [0.3 s] -✔ | 12 | Special cases of mkinfit calls [0.7 s] +✔ | 12 | Special cases of mkinfit calls [0.8 s] ✔ | 8 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.4 s] ✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.6 s] -✔ | 9 | Nonlinear mixed-effects models [7.7 s] -✔ | 18 | Plotting [2.1 s] +✔ | 9 | Nonlinear mixed-effects models [7.8 s] +✖ | 15 1 | Plotting [2.0 s] +──────────────────────────────────────────────────────────────────────────────── +FAILURE (test_plot.R:26:3): Plotting mkinfit and mmkin objects is reproducible +Figures don't match: mmkin-plot-for-sfo-focus-c-and-d.svg + +──────────────────────────────────────────────────────────────────────────────── ✔ | 4 | Residuals extracted from mkinfit models -✔ | 17 | Nonlinear mixed effects models fitted with SAEM from saemix [19.1 s] -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.5 s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.6 s] ✔ | 4 | Summary [0.1 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.3 s] -✔ | 9 | Hypothesis tests [7.4 s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] +✔ | 9 | Hypothesis tests [7.3 s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 62.0 s +Duration: 50.0 s -[ FAIL 0 | WARN 0 | SKIP 0 | PASS 189 ] +[ FAIL 1 | WARN 0 | SKIP 0 | PASS 192 ] diff --git a/tests/testthat/print_mmkin_parent.txt b/tests/testthat/print_mmkin_parent.txt new file mode 100644 index 00000000..620a657a --- /dev/null +++ b/tests/testthat/print_mmkin_parent.txt @@ -0,0 +1,13 @@ + object +Status of individual fits: + + dataset +model FOCUS_A FOCUS_C FOCUS_D + SFO OK OK OK + FOMC C OK OK + DFOP OK OK OK + HS OK OK OK + +OK: No warnings +C: Optimisation did not converge: +false convergence (8) diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index e3b56fb3..9da8b90d 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -35,7 +35,7 @@ f_1_mkin_notrans <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE, # mmkin object of parent fits for tests models <- c("SFO", "FOMC", "DFOP", "HS") fits <- mmkin(models, - list(FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), + list(FOCUS_A = FOCUS_2006_A, FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), quiet = TRUE, cores = n_cores) # One metabolite diff --git a/tests/testthat/test_error_models.R b/tests/testthat/test_error_models.R index 169001f1..2a1ffcc1 100644 --- a/tests/testthat/test_error_models.R +++ b/tests/testthat/test_error_models.R @@ -56,7 +56,6 @@ test_that("The default error model algorithm finds the best known AIC values for f_tc_exp_d_3 <- mmkin(c("SFO", "DFOP", "HS"), lapply(experimental_data_for_UBA_2019, function(x) x$data), error_model = "tc", - error_model_algorithm = "d_3", quiet = TRUE) AIC_exp_d_3 <- lapply(f_tc_exp_d_3, AIC) diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R index ef73f21d..644cccc1 100644 --- a/tests/testthat/test_mixed.R +++ b/tests/testthat/test_mixed.R @@ -2,7 +2,8 @@ context("Nonlinear mixed effects models") test_that("Parent only models can be fitted using nonlinear mixed effects models", { # Some fits were done in the setup script - mmkin_sfo_2 <- mmkin("SFO", ds_sfo, fixed_initials = c(parent = 100), quiet = TRUE) + mmkin_sfo_2 <- update(mmkin_sfo_1, fixed_initials = c(parent = 100)) + expect_error(update(mmkin_sfo_1, models = c("SFOOO")), "Please supply models.*") sfo_saemix_2 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "mkin") sfo_saemix_3 <- expect_error(saem(mmkin_sfo_2, quiet = TRUE), "at least two parameters") @@ -45,6 +46,7 @@ test_that("Parent only models can be fitted using nonlinear mixed effects models }) test_that("Print methods work", { + expect_known_output(print(fits, digits = 2), "print_mmkin_parent.txt") expect_known_output(print(mmkin_biphasic_mixed, digits = 2), "print_mmkin_biphasic_mixed.txt") expect_known_output(print(nlme_biphasic, digits = 1), "print_nlme_biphasic.txt") expect_known_output(print(sfo_saemix_1, digits = 1), "print_sfo_saemix_1.txt") -- cgit v1.2.1