From 241f0b977092e4fe106a23ef70506bf37c1a3609 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 25 Feb 2019 17:05:59 +0100 Subject: Fix tests and add plot and print for nafta --- build.log | 3 + test.log | 15 +- .../plot-nafta-analysis-sop-appendix-d.svg | 450 +++++++++++++++++++++ tests/testthat/print_nafta_analysis.txt | 33 ++ tests/testthat/summary_DFOP_FOCUS_C.txt | 2 +- tests/testthat/test_nafta.R | 9 +- tests/testthat/test_plots_summary_twa.R | 4 +- 7 files changed, 505 insertions(+), 11 deletions(-) create mode 100644 tests/figs/evaluations-according-to-the-nafta-guidance-from-2015/plot-nafta-analysis-sop-appendix-d.svg create mode 100644 tests/testthat/print_nafta_analysis.txt diff --git a/build.log b/build.log index 6831459d..e7e1addc 100644 --- a/build.log +++ b/build.log @@ -7,4 +7,7 @@ * checking for empty or unneeded directories * looking to see if a ‘data/datalist’ file should be added * building ‘mkin_0.9.48.1.tar.gz’ +Warnung in utils::tar(filepath, pkgname, compression = "gzip", compression_level = 9L, + storing paths of more than 100 bytes is not portable: + ‘mkin/tests/figs/evaluations-according-to-the-nafta-guidance-from-2015/plot-nafta-analysis-sop-appendix-d.svg’ diff --git a/test.log b/test.log index 345746e2..df597cfa 100644 --- a/test.log +++ b/test.log @@ -14,17 +14,20 @@ test_logistic.R:41: skip: The logistic fit can be done via differential equation Skip slow fit of logistic model using deSolve without compilation ──────────────────────────────────────────────────────────────────────────────── ⠏ | 0 | Model predictions with mkinpredict ⠋ | 1 | Model predictions with mkinpredict ⠙ | 2 | Model predictions with mkinpredict ⠹ | 3 | Model predictions with mkinpredict ✔ | 3 | Model predictions with mkinpredict [0.3 s] - ⠏ | 0 | Evaluations according to the NAFTA guidance from 2015 ⠋ | 1 | Evaluations according to the NAFTA guidance from 2015 ⠙ | 1 1 | Evaluations according to the NAFTA guidance from 2015 ⠙ | 2 | Evaluations according to the NAFTA guidance from 2015 ⠹ | 3 | Evaluations according to the NAFTA guidance from 2015 ⠸ | 4 | Evaluations according to the NAFTA guidance from 2015 ⠼ | 5 | Evaluations according to the NAFTA guidance from 2015 ⠴ | 6 | Evaluations according to the NAFTA guidance from 2015 ⠦ | 7 | Evaluations according to the NAFTA guidance from 2015 ✔ | 7 | Evaluations according to the NAFTA guidance from 2015 [0.7 s] - ⠏ | 0 | Fitting of parent only models ⠋ | 1 | Fitting of parent only models ⠙ | 2 | Fitting of parent only models ⠹ | 3 | Fitting of parent only models ⠸ | 4 | Fitting of parent only models ⠼ | 5 | Fitting of parent only models ⠴ | 6 | Fitting of parent only models ⠦ | 7 | Fitting of parent only models ⠧ | 8 | Fitting of parent only models ⠇ | 9 | Fitting of parent only models ⠏ | 10 | Fitting of parent only models ⠋ | 11 | Fitting of parent only models ⠙ | 12 | Fitting of parent only models ⠹ | 13 | Fitting of parent only models ⠸ | 14 | Fitting of parent only models ⠼ | 15 | Fitting of parent only models ⠴ | 16 | Fitting of parent only models ⠦ | 17 | Fitting of parent only models ⠧ | 18 | Fitting of parent only models ⠇ | 19 | Fitting of parent only models ⠏ | 20 | Fitting of parent only models ⠋ | 21 | Fitting of parent only models ✔ | 21 | Fitting of parent only models [23.8 s] + ⠏ | 0 | Evaluations according to the NAFTA guidance from 2015 ⠋ | 1 | Evaluations according to the NAFTA guidance from 2015 ⠙ | 1 1 | Evaluations according to the NAFTA guidance from 2015 ⠙ | 2 | Evaluations according to the NAFTA guidance from 2015 ⠹ | 3 | Evaluations according to the NAFTA guidance from 2015 ⠸ | 4 | Evaluations according to the NAFTA guidance from 2015 ⠼ | 5 | Evaluations according to the NAFTA guidance from 2015 ⠴ | 6 | Evaluations according to the NAFTA guidance from 2015 ⠦ | 7 | Evaluations according to the NAFTA guidance from 2015 ⠧ | 8 | Evaluations according to the NAFTA guidance from 2015 ⠇ | 9 | Evaluations according to the NAFTA guidance from 2015 ✔ | 9 | Evaluations according to the NAFTA guidance from 2015 [0.9 s] + ⠏ | 0 | Fitting of parent only models ⠋ | 1 | Fitting of parent only models ⠙ | 2 | Fitting of parent only models ⠹ | 3 | Fitting of parent only models ⠸ | 4 | Fitting of parent only models ⠼ | 5 | Fitting of parent only models ⠴ | 6 | Fitting of parent only models ⠦ | 7 | Fitting of parent only models ⠧ | 8 | Fitting of parent only models ⠇ | 9 | Fitting of parent only models ⠏ | 10 | Fitting of parent only models ⠋ | 11 | Fitting of parent only models ⠙ | 12 | Fitting of parent only models ⠹ | 13 | Fitting of parent only models ⠸ | 14 | Fitting of parent only models ⠼ | 15 | Fitting of parent only models ⠴ | 16 | Fitting of parent only models ⠦ | 17 | Fitting of parent only models ⠧ | 18 | Fitting of parent only models ⠇ | 19 | Fitting of parent only models ⠏ | 20 | Fitting of parent only models ⠋ | 21 | Fitting of parent only models ✔ | 21 | Fitting of parent only models [23.9 s] ⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) ⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) ⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) ⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) ⠸ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ⠼ | 5 | Calculation of maximum time weighted average concentrations (TWAs) ⠴ | 6 | Calculation of maximum time weighted average concentrations (TWAs) ⠦ | 7 | Calculation of maximum time weighted average concentrations (TWAs) ⠧ | 8 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 8 | Calculation of maximum time weighted average concentrations (TWAs) [7.2 s] - ⠏ | 0 | Plotting ⠋ | 1 | Plotting ⠙ | 2 | Plotting ✔ | 2 | Plotting [0.4 s] + ⠏ | 0 | Summary ⠋ | 1 | Summary ✔ | 1 | Summary + ⠏ | 0 | Plotting ⠋ | 1 | Plotting ⠙ | 2 | Plotting ⠹ | 3 | Plotting ✔ | 3 | Plotting [0.3 s] + ⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) ⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) ⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) ⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) ⠸ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ⠼ | 5 | Calculation of maximum time weighted average concentrations (TWAs) ⠴ | 6 | Calculation of maximum time weighted average concentrations (TWAs) ⠦ | 7 | Calculation of maximum time weighted average concentrations (TWAs) ⠧ | 8 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 8 | Calculation of maximum time weighted average concentrations (TWAs) [7.8 s] + ⠏ | 0 | Plotting ⠋ | 1 | Plotting ⠙ | 2 | Plotting ⠹ | 3 | Plotting ✔ | 3 | Plotting [0.3 s] ⠏ | 0 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠋ | 1 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠙ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.9 s] - ⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.5 s] + ⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.4 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 65.9 s +Duration: 75.0 s -OK: 59 +OK: 74 Failed: 0 Warnings: 0 Skipped: 2 diff --git a/tests/figs/evaluations-according-to-the-nafta-guidance-from-2015/plot-nafta-analysis-sop-appendix-d.svg b/tests/figs/evaluations-according-to-the-nafta-guidance-from-2015/plot-nafta-analysis-sop-appendix-d.svg new file mode 100644 index 00000000..58f57e93 --- /dev/null +++ b/tests/figs/evaluations-according-to-the-nafta-guidance-from-2015/plot-nafta-analysis-sop-appendix-d.svg @@ -0,0 +1,450 @@ + + + + + + + + + + + +0 +100 +200 +300 + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +MRID 555555 +SFO + +χ +2 + +error level += +9.04% + + + + + + + + + + + + + + + + +0 +100 +200 +300 +400 + + + + + + +-20 +-10 +0 +10 +20 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +SFO residuals + + + + + + + + + + + + + + + +0 +100 +200 +300 + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +MRID 555555 +IORE + +χ +2 + +error level += +5.65% + + + + + + + + + + + + + + + + +0 +100 +200 +300 +400 + + + + + + +-20 +-10 +0 +10 +20 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +IORE residuals + + + + + + + + + + + + + + + +0 +100 +200 +300 + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +MRID 555555 +DFOP + +χ +2 + +error level += +5.25% + + + + + + + + + + + + + + + + +0 +100 +200 +300 +400 + + + + +-10 +0 +10 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +DFOP residuals + + + + + + diff --git a/tests/testthat/print_nafta_analysis.txt b/tests/testthat/print_nafta_analysis.txt new file mode 100644 index 00000000..61d2539f --- /dev/null +++ b/tests/testthat/print_nafta_analysis.txt @@ -0,0 +1,33 @@ +Sums of squares: + SFO IORE DFOP +1378.6832 615.7730 517.8836 +[1] 717.4598 + +Parameters: +$SFO + Estimate Pr(>t) Lower Upper +parent_0 83.755751519 8.076390e-15 76.928220975 90.583282063 +k_parent_sink 0.001703321 7.452357e-05 0.001108568 0.002617164 + +$IORE + Estimate Pr(>t) Lower Upper +parent_0 9.685291e+01 NA 8.752855e+01 1.061773e+02 +k__iore_parent_sink 8.403374e-14 NA 1.092054e-19 6.466412e-08 +N_parent 6.684458e+00 NA 3.538511e+00 9.830405e+00 + +$DFOP + Estimate Pr(>t) Lower Upper +parent_0 9.755655e+01 4.439930e-13 8.884447e+01 1.062686e+02 +k1 4.240633e-02 3.554769e-02 1.414189e-02 1.271610e-01 +k2 8.237928e-04 2.060933e-02 3.172784e-04 2.138925e-03 +g 2.881037e-01 1.313715e-04 1.783967e-01 4.299694e-01 + + +DTx values: + DT50 DT90 DT50_rep +SFO 407 1352 407 +IORE 541 5192066 1562968 +DFOP 429 2383 841 + +Representative half-life: +[1] 841.4096 diff --git a/tests/testthat/summary_DFOP_FOCUS_C.txt b/tests/testthat/summary_DFOP_FOCUS_C.txt index d8a3e05a..33d55ebc 100644 --- a/tests/testthat/summary_DFOP_FOCUS_C.txt +++ b/tests/testthat/summary_DFOP_FOCUS_C.txt @@ -10,7 +10,7 @@ d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * Model predictions using solution type analytical -Fitted with method Port using 127 model solutions performed in 0.401 s +Fitted with method Port using test 0 model solutions performed in test time 0 s Weighting: none diff --git a/tests/testthat/test_nafta.R b/tests/testthat/test_nafta.R index 7d650ad8..3615c278 100644 --- a/tests/testthat/test_nafta.R +++ b/tests/testthat/test_nafta.R @@ -16,9 +16,6 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see -library(testthat) -library(mkin) - context("Evaluations according to the NAFTA guidance from 2015") test_that("Data for more than one compound are rejected", @@ -31,6 +28,7 @@ test_that("Test data from Appendix D are correctly evaluated", { dtx_sop <- matrix(c(407, 541, 429, 1352, 5192066, 2383), nrow = 3, ncol = 2) expect_equivalent(res$distimes[, 1:2], dtx_sop, tolerance = 1, scale = 1) + C0_sop <- c(SFO = 83.8, IORE = 96.9, DFOP = 97.6) C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"]) expect_equivalent(C0_mkin, C0_sop, scale = 1, tolerance = 0.1) @@ -38,4 +36,9 @@ test_that("Test data from Appendix D are correctly evaluated", { expect_equal(round(res$S_c), 717) expect_equal(signif(res$S[["SFO"]], 3), 1.38e+3) expect_equal(round(res$t_rep), 841) + + expect_known_output(print(res), "print_nafta_analysis.txt") + + plot_nafta <- function() plot(res) + vdiffr::expect_doppelganger("Plot NAFTA analysis SOP Appendix D", plot_nafta) }) diff --git a/tests/testthat/test_plots_summary_twa.R b/tests/testthat/test_plots_summary_twa.R index 83a6a040..d5f4f199 100644 --- a/tests/testthat/test_plots_summary_twa.R +++ b/tests/testthat/test_plots_summary_twa.R @@ -53,11 +53,13 @@ context("Summary") test_that("The summary is reproducible", { skip_on_cran() fit <- fits[["DFOP", "FOCUS_C"]] - undebug(summary.mkinfit) + test_summary <- summary(fit) test_summary$fit_version <- "Dummy 0.0 for testing" test_summary$fit_Rversion <- "Dummy R version for testing" test_summary$date.fit <- "Dummy date for testing" test_summary$date.summary <- "Dummy date for testing" + test_summary$calls <- "test 0" + test_summary$time <- c(elapsed = "test time 0") expect_known_output(print(test_summary), "summary_DFOP_FOCUS_C.txt") }) -- cgit v1.2.1