From d75cc396f3e93b06ba1c7a165543fe885ff9c69c Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 8 Apr 2020 09:57:53 +0200 Subject: Make the nlme test file work with testthat --- test.log | 29 ++++++++++------------------- tests/testthat/FOCUS_2006_D.csf | 2 +- tests/testthat/test_nlme.R | 7 +++++-- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/test.log b/test.log index 877d5193..09dd4c3f 100644 --- a/test.log +++ b/test.log @@ -7,42 +7,33 @@ Testing mkin ✔ | 4 | Fitting the SFORB model [1.7 s] ✔ | 5 | Calculation of Akaike weights ✔ | 10 | Confidence intervals and p-values [9.4 s] -✔ | 14 | Error model fitting [37.5 s] +✔ | 14 | Error model fitting [38.4 s] ✔ | 6 | Test fitting the decline of metabolites from their maximum [0.8 s] ✔ | 1 | Fitting the logistic model [0.9 s] ✔ | 1 | Test dataset class mkinds used in gmkin -✔ | 12 | Special cases of mkinfit calls [2.3 s] +✔ | 12 | Special cases of mkinfit calls [2.4 s] ✔ | 9 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.3 s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.1 s] -✖ | 0 1 | Nonlinear mixed-effects models [1.3 s] -──────────────────────────────────────────────────────────────────────────────── -test_nlme.R:37: error: nlme_function works correctly -konnte Funktion "nlme_f" nicht finden -Backtrace: - 1. nlme::nlme(...) tests/testthat/test_nlme.R:37:2 - 2. nlme::nlme.formula(...) - 3. [ base::eval(...) ] with 1 more call - 5. [ base::eval(...) ] with 1 more call -──────────────────────────────────────────────────────────────────────────────── +✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.2 s] +✔ | 3 | Nonlinear mixed-effects models [2.1 s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2 s] ✔ | 3 | Summary ✔ | 11 | Plotting [0.6 s] ✔ | 4 | AIC calculation ✔ | 2 | Residuals extracted from mkinfit models -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.5 s] ✔ | 1 | Summaries of old mkinfit objects -✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.0 s] -✔ | 7 1 | Hypothesis tests [31.9 s] +✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.2 s] +✔ | 7 1 | Hypothesis tests [34.0 s] ──────────────────────────────────────────────────────────────────────────────── test_tests.R:60: skip: We can do a likelihood ratio test using an update specification Reason: This errors out if called by testthat while it works in a normal R session ──────────────────────────────────────────────────────────────────────────────── ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 111.4 s +Duration: 115.8 s -OK: 138 -Failed: 1 +OK: 141 +Failed: 0 Warnings: 0 Skipped: 1 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index f492a57f..118f61f4 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2020-04-07 +Date: 2020-04-08 Optimiser: IRLS [Data] diff --git a/tests/testthat/test_nlme.R b/tests/testthat/test_nlme.R index b3c41f00..31db92e1 100644 --- a/tests/testthat/test_nlme.R +++ b/tests/testthat/test_nlme.R @@ -26,7 +26,11 @@ test_that("nlme_function works correctly", { mean_dp <- mean_degparms(f) grouped_data <- nlme_data(f) + nlme_f <- nlme_function(f) + # The following assignment was introduced for nlme as evaluated by testthat + # to find the function + assign("nlme_f", nlme_f, pos = globalenv()) m_nlme_raw <- nlme(value ~ SSasymp(time, 0, parent_0, log_k_parent_sink), data = grouped_data, @@ -58,6 +62,5 @@ test_that("nlme_function works correctly", { m_nlme_mkin_up_2 <- update(m_nlme_mkin, random = parent_0 ~ 1) expect_equal(m_nlme_raw_up_2$coefficients, m_nlme_mkin_up_2$coefficients) - # update(m_nlme_mkin) # works - + expect_silent(tmp <- update(m_nlme_mkin)) }) -- cgit v1.2.1