From ab502a6aeacda7c70abe52b8c16e2a15f592a6ed Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 12 Jul 2022 14:44:55 +0200 Subject: Tests before release --- test.log | 55 +- .../plot/mixed-model-fit-for-nlme-object.new.svg | 1367 +++++++++++ ...r-saem-object-with-mkin-transformations.new.svg | 2502 ++++++++++++++++++++ tests/testthat/setup_script.R | 2 +- vignettes/web_only/benchmarks.R | 112 - 5 files changed, 3906 insertions(+), 132 deletions(-) create mode 100644 tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg create mode 100644 tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg delete mode 100644 vignettes/web_only/benchmarks.R diff --git a/test.log b/test.log index 4e634f93..55a56153 100644 --- a/test.log +++ b/test.log @@ -3,19 +3,19 @@ Loading required package: parallel ℹ Testing mkin ✔ | F W S OK | Context ✔ | 5 | AIC calculation -✔ | 5 | Analytical solutions for coupled models [2.9s] +✔ | 5 | Analytical solutions for coupled models [3.2s] ✔ | 5 | Calculation of Akaike weights ✔ | 3 | Export dataset for reading into CAKE -✔ | 12 | Confidence intervals and p-values [0.9s] -✔ | 1 12 | Dimethenamid data from 2018 [32.4s] +✔ | 12 | Confidence intervals and p-values [1.0s] +✔ | 1 12 | Dimethenamid data from 2018 [32.1s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_dmta.R:98:3): Different backends get consistent results for SFO-SFO3+, dimethenamid data Reason: Fitting this ODE model with saemix takes about 15 minutes on my system ──────────────────────────────────────────────────────────────────────────────── -✔ | 14 | Error model fitting [6.6s] +✔ | 14 | Error model fitting [4.8s] ✔ | 5 | Time step normalisation -✔ | 4 | Calculation of FOCUS chi2 error levels [0.5s] -✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.7s] +✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s] +✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s] ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3s] ✔ | 1 | Fitting the logistic model [0.2s] ✔ | 1 12 | Nonlinear mixed-effects models [0.2s] @@ -24,28 +24,45 @@ Skip (test_mixed.R:68:3): saemix results are reproducible for biphasic fits Reason: Fitting with saemix takes around 10 minutes when using deSolve ──────────────────────────────────────────────────────────────────────────────── ✔ | 3 | Test dataset classes mkinds and mkindsg -✔ | 10 | Special cases of mkinfit calls [0.3s] -✔ | 3 | mkinfit features [0.6s] +✔ | 10 | Special cases of mkinfit calls [0.4s] +✔ | 3 | mkinfit features [0.7s] ✔ | 8 | mkinmod model generation and printing [0.2s] -✔ | 3 | Model predictions with mkinpredict [0.3s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.3s] -✔ | 9 | Nonlinear mixed-effects models with nlme [7.9s] -✔ | 16 | Plotting [10.2s] +✔ | 3 | Model predictions with mkinpredict [0.4s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.5s] +✔ | 9 | Nonlinear mixed-effects models with nlme [8.1s] +✖ | 2 14 | Plotting [10.5s] +──────────────────────────────────────────────────────────────────────────────── +Failure (test_plot.R:56:3): Plotting mkinfit, mmkin and mixed model objects is reproducible +Snapshot of `testcase` to 'plot/mixed-model-fit-for-nlme-object.svg' has changed +Run `testthat::snapshot_review('plot/')` to review changes +Backtrace: + 1. vdiffr::expect_doppelganger(...) + at test_plot.R:56:2 + 3. testthat::expect_snapshot_file(...) + +Failure (test_plot.R:64:3): Plotting mkinfit, mmkin and mixed model objects is reproducible +Snapshot of `testcase` to 'plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg' has changed +Run `testthat::snapshot_review('plot/')` to review changes +Backtrace: + 1. vdiffr::expect_doppelganger(...) + at test_plot.R:64:2 + 3. testthat::expect_snapshot_file(...) +──────────────────────────────────────────────────────────────────────────────── ✔ | 4 | Residuals extracted from mkinfit models -✔ | 25 | saemix parent models [157.4s] +✔ | 25 | saemix parent models [171.7s] ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.3s] -✔ | 7 | Fitting the SFORB model [3.2s] +✔ | 7 | Fitting the SFORB model [3.6s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Summary [0.1s] -✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [1.9s] -✔ | 9 | Hypothesis tests [6.6s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [1.8s] +✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.1s] +✔ | 9 | Hypothesis tests [7.7s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 238.2 s +Duration: 254.3 s ── Skipped tests ────────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 15 minutes on my system (1) • Fitting with saemix takes around 10 minutes when using deSolve (1) -[ FAIL 0 | WARN 0 | SKIP 2 | PASS 224 ] +[ FAIL 2 | WARN 0 | SKIP 2 | PASS 222 ] diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg new file mode 100644 index 00000000..051b46b1 --- /dev/null +++ b/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg @@ -0,0 +1,1367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Population +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + + + +Time +Residues parent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 + + + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg new file mode 100644 index 00000000..375ab089 --- /dev/null +++ b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg @@ -0,0 +1,2502 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Population +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + + + +Time +Residues parent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 + + + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +10 +20 +30 +40 + + + + + + + + +Time +Residues m1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 + + + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 8ffe0b9d..62cdf78e 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -1,7 +1,7 @@ require(mkin) require(testthat) -# Per default (on my box where I set NOT_CRAN) use all cores minus one +# Per default (on my box where I set NOT_CRAN in .Rprofile) use all cores minus one if (identical(Sys.getenv("NOT_CRAN"), "true")) { n_cores <- parallel::detectCores() - 1 } else { diff --git a/vignettes/web_only/benchmarks.R b/vignettes/web_only/benchmarks.R deleted file mode 100644 index c9ba5be3..00000000 --- a/vignettes/web_only/benchmarks.R +++ /dev/null @@ -1,112 +0,0 @@ -## ---- include = FALSE--------------------------------------------------------- -library(knitr) -opts_chunk$set(tidy = FALSE, cache = FALSE) -library("mkin") - -## ----include = FALSE---------------------------------------------------------- -cpu_model <- benchmarkme::get_cpu()$model_name -# Abbreviate CPU identifiers -cpu_model <- gsub("AMD ", "", cpu_model) -cpu_model <- gsub("Intel\\(R\\) Core\\(TM\\) ", "", cpu_model) -cpu_model <- gsub(" Eight-Core Processor", "", cpu_model) -cpu_model <- gsub(" CPU @ 2.50GHz", "", cpu_model) - -operating_system <- Sys.info()[["sysname"]] -mkin_version <- as.character(packageVersion("mkin")) -R_version <- paste0(R.version$major, ".", R.version$minor) -system_string <- paste0(operating_system, ", ", cpu_model, ", mkin ", mkin_version, ", R ", R_version) - -benchmark_path = normalizePath("~/git/mkin/vignettes/web_only/mkin_benchmarks.rda") -load(benchmark_path) - -# Used for reformatting the data on 2022-06-30 -# mkin_benchmarks[, "R"] <- NA -# mkin_benchmarks <- mkin_benchmarks[c(2, 1, 15, 3, 4:14)] -# mkin_benchmarks[, "CPU"] <- gsub("AMD.*", "Ryzen 7 1700", mkin_benchmarks[, "CPU"]) -# mkin_benchmarks[, "CPU"] <- gsub("Intel.*", "i7-4710MQ", mkin_benchmarks[, "CPU"]) -# rownames(mkin_benchmarks) <- gsub("AMD Ryzen 7 1700 Eight-Core Processor", "Ryzen 7 1700", rownames(mkin_benchmarks)) -# rownames(mkin_benchmarks) <- gsub("Intel\\(R\\) Core\\(TM\\) i7-4710MQ CPU @ 2.50GHz", "i7-4710MQ", rownames(mkin_benchmarks)) -# rownames(mkin_benchmarks) <- gsub(" version", "", rownames(mkin_benchmarks)) - -mkin_benchmarks[system_string, c("CPU", "OS", "mkin", "R")] <- - c(cpu_model, operating_system, mkin_version, R_version) - -if (mkin_version > "0.9.48.1") { - mmkin_bench <- function(models, datasets, error_model = "const") { - mmkin(models, datasets, error_model = error_model, cores = 1, quiet = TRUE) - } -} else { - mmkin_bench <- function(models, datasets, error_model = NULL) { - mmkin(models, datasets, reweight.method = error_model, cores = 1, quiet = TRUE) - } -} - -## ----parent_only, warning = FALSE--------------------------------------------- -FOCUS_C <- FOCUS_2006_C -FOCUS_D <- subset(FOCUS_2006_D, value != 0) -parent_datasets <- list(FOCUS_C, FOCUS_D) - -t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets))[["elapsed"]] -t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets, - error_model = "tc"))[["elapsed"]] - -## ----one_metabolite, message = FALSE------------------------------------------ -SFO_SFO <- mkinmod( - parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO")) -FOMC_SFO <- mkinmod( - parent = mkinsub("FOMC", "m1"), - m1 = mkinsub("SFO")) -DFOP_SFO <- mkinmod( - parent = mkinsub("FOMC", "m1"), - m1 = mkinsub("SFO")) -t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D)))[["elapsed"]] -t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), - error_model = "tc"))[["elapsed"]] -t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), - error_model = "obs"))[["elapsed"]] - -## ----two_metabolites, message = FALSE----------------------------------------- -m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), - M1 = mkinsub("SFO", "M2"), - M2 = mkinsub("SFO"), - use_of_ff = "max", quiet = TRUE) - -m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")), - M1 = mkinsub("SFO"), - M2 = mkinsub("SFO"), - use_of_ff = "max", quiet = TRUE) - -SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data - -DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data - -t6 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a)))[["elapsed"]] -t7 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c)))[["elapsed"]] - -t8 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), - error_model = "tc"))[["elapsed"]] -t9 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), - error_model = "tc"))[["elapsed"]] - -t10 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), - error_model = "obs"))[["elapsed"]] -t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), - error_model = "obs"))[["elapsed"]] - -## ----results------------------------------------------------------------------ -mkin_benchmarks[system_string, paste0("t", 1:11)] <- - c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) -save(mkin_benchmarks, file = benchmark_path) -# Hide rownames from kable for results section -rownames(mkin_benchmarks) <- NULL - -## ---- echo = FALSE------------------------------------------------------------ -kable(mkin_benchmarks[, c(1:4, 5:6)]) - -## ---- echo = FALSE------------------------------------------------------------ -kable(mkin_benchmarks[, c(1:4, 7:9)]) - -## ---- echo = FALSE------------------------------------------------------------ -kable(mkin_benchmarks[, c(1:4, 10:15)]) - -- cgit v1.2.1