aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-11-18 20:35:06 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2022-11-18 20:35:06 +0100
commitb6b7e387261e5483f1bdfafaaa975e2f24c6567c (patch)
treee8b4acc4173054abaf6b15ad219f86be82d4f1b4
parent317fd7514e638780c09ed6349a165a854ba2deea (diff)
Use cluster with two cores to reduce windows check time
-rw-r--r--NEWS.md2
-rw-r--r--docs/news/index.html3
-rw-r--r--docs/pkgdown.yml2
-rw-r--r--log/test.log37
-rw-r--r--tests/testthat/setup_script.R22
-rw-r--r--tests/testthat/test_saemix_parent.R2
6 files changed, 40 insertions, 28 deletions
diff --git a/NEWS.md b/NEWS.md
index 245a3973..c4c3ddee 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,7 @@
# mkin 1.2.1 (unreleased)
+- '{data,R}/ds_mixed.rda': Include the test data in the package instead of generating it in 'tests/testthat/setup_script.R'. Refactor the generating code to make it consistent and update tests.
+
- 'tests/testthat/setup_script.R': Excluded another ill-defined random effect for the DFOP fit with 'saem', in an attempt to avoid a platform dependence that surfaced on Fedora systems on the CRAN check farm
- 'tests/testthat/test_mixed.R': Round parameters found by saemix to two significant digits before printing, to also help to avoid platform dependence of tests
diff --git a/docs/news/index.html b/docs/news/index.html
index 6b9a7d51..f6883766 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -89,7 +89,8 @@
<div class="section level2">
<h2 class="page-header" data-toc-text="1.2.1" id="mkin-121-unreleased">mkin 1.2.1 (unreleased)<a class="anchor" aria-label="anchor" href="#mkin-121-unreleased"></a></h2>
-<ul><li><p>‘tests/testthat/setup_script.R’: Excluded another ill-defined random effect for the DFOP fit with ‘saem’, in an attempt to avoid a platform dependence that surfaced on Fedora systems on the CRAN check farm</p></li>
+<ul><li><p>‘{data,R}/ds_mixed.rda’: Include the test data in the package instead of generating it in ‘tests/testthat/setup_script.R’. Refactor the generating code to make it consistent and update tests.</p></li>
+<li><p>‘tests/testthat/setup_script.R’: Excluded another ill-defined random effect for the DFOP fit with ‘saem’, in an attempt to avoid a platform dependence that surfaced on Fedora systems on the CRAN check farm</p></li>
<li><p>‘tests/testthat/test_mixed.R’: Round parameters found by saemix to two significant digits before printing, to also help to avoid platform dependence of tests</p></li>
<li><p>‘R/saem.R’: Fix a bug that prevented that ‘error.ini’ is passed to ‘saemix_model’, and set default to c(1, 1) to avoid changing test results</p></li>
<li><p>‘R/parplot.R’: Show initial values for error model parameters</p></li>
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index b6c8f1cc..7cf87069 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -13,7 +13,7 @@ articles:
dimethenamid_2018: web_only/dimethenamid_2018.html
multistart: web_only/multistart.html
saem_benchmarks: web_only/saem_benchmarks.html
-last_built: 2022-11-18T18:18Z
+last_built: 2022-11-18T18:28Z
urls:
reference: https://pkgdown.jrwb.de/mkin/reference
article: https://pkgdown.jrwb.de/mkin/articles
diff --git a/log/test.log b/log/test.log
index d1de270e..8fdaec48 100644
--- a/log/test.log
+++ b/log/test.log
@@ -1,53 +1,53 @@
ℹ Testing mkin
✔ | F W S OK | Context
✔ | 5 | AIC calculation
-✔ | 5 | Analytical solutions for coupled models [3.3s]
+✔ | 5 | Analytical solutions for coupled models [3.4s]
✔ | 5 | Calculation of Akaike weights
✔ | 3 | Export dataset for reading into CAKE
-✔ | 12 | Confidence intervals and p-values [1.0s]
-✔ | 1 12 | Dimethenamid data from 2018 [32.6s]
+✔ | 12 | Confidence intervals and p-values [1.2s]
+✔ | 1 12 | Dimethenamid data from 2018 [34.0s]
────────────────────────────────────────────────────────────────────────────────
Skip ('test_dmta.R:98'): 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 [5.1s]
+✔ | 14 | Error model fitting [5.4s]
✔ | 5 | Time step normalisation
✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s]
-✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s]
+✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.9s]
✔ | 4 | Test fitting the decline of metabolites from their maximum [0.4s]
-✔ | 1 | Fitting the logistic model [0.2s]
-✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [24.6s]
+✔ | 1 | Fitting the logistic model [0.3s]
+✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [25.8s]
✔ | 1 13 | Nonlinear mixed-effects models [0.4s]
────────────────────────────────────────────────────────────────────────────────
Skip ('test_mixed.R:79'): 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.5s]
+✔ | 10 | Special cases of mkinfit calls [0.6s]
✔ | 3 | mkinfit features [0.7s]
✔ | 8 | mkinmod model generation and printing [0.2s]
✔ | 3 | Model predictions with mkinpredict [0.4s]
-✔ | 9 | Multistart method for saem.mmkin models [37.3s]
-✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.5s]
+✔ | 9 | Multistart method for saem.mmkin models [38.2s]
+✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.4s]
✔ | 9 | Nonlinear mixed-effects models with nlme [9.2s]
-✔ | 16 | Plotting [10.1s]
+✔ | 16 | Plotting [10.5s]
✔ | 4 | Residuals extracted from mkinfit models
-✔ | 1 36 | saemix parent models [71.4s]
+✔ | 1 36 | saemix parent models [75.0s]
────────────────────────────────────────────────────────────────────────────────
Skip ('test_saemix_parent.R:143'): We can also use mkin solution methods for saem
Reason: This still takes almost 2.5 minutes although we do not solve ODEs
────────────────────────────────────────────────────────────────────────────────
-✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.4s]
+✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.6s]
✔ | 11 | Processing of residue series
-✔ | 10 | Fitting the SFORB model [3.9s]
+✔ | 10 | Fitting the SFORB model [4.0s]
✔ | 1 | Summaries of old mkinfit objects
✔ | 5 | Summary [0.2s]
-✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.3s]
-✔ | 9 | Hypothesis tests [8.3s]
-✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2s]
+✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.5s]
+✔ | 9 | Hypothesis tests [9.0s]
+✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3s]
══ Results ═════════════════════════════════════════════════════════════════════
-Duration: 220.0 s
+Duration: 229.5 s
── Skipped tests ──────────────────────────────────────────────────────────────
• Fitting this ODE model with saemix takes about 15 minutes on my system (1)
@@ -55,3 +55,4 @@ Duration: 220.0 s
• This still takes almost 2.5 minutes although we do not solve ODEs (1)
[ FAIL 0 | WARN 0 | SKIP 3 | PASS 270 ]
+Error while shutting down parallel: unable to terminate some child processes
diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R
index c554800d..2448886d 100644
--- a/tests/testthat/setup_script.R
+++ b/tests/testthat/setup_script.R
@@ -2,17 +2,23 @@ require(mkin)
require(testthat)
# Per default (on my box where I set NOT_CRAN in .Rprofile) use all cores minus one
+# Otherwise (CRAN check systems) use the allowed maximum of two cores
if (identical(Sys.getenv("NOT_CRAN"), "true")) {
n_cores <- parallel::detectCores() - 1
} else {
- n_cores <- 1
+ n_cores <- 2
}
# Use the two available cores on travis
if (Sys.getenv("TRAVIS") != "") n_cores = 2
-# On Windows we would need to make a cluster first
-if (Sys.info()["sysname"] == "Windows") n_cores = 1
+# On Windows we need to make a cluster, or use one core
+if (Sys.info()["sysname"] == "Windows") {
+ cl <- parallel::makePSOCKcluster(n_cores)
+ n_cores = 1
+} else {
+ cl <- parallel::makeForkCluster(n_cores)
+}
# Very simple example fits
f_1_mkin_trans <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE)
@@ -24,7 +30,7 @@ models <- c("SFO", "FOMC", "DFOP", "HS")
fits <- suppressWarnings( # FOCUS A FOMC was, it seems, in testthat output
mmkin(models,
list(FOCUS_A = FOCUS_2006_A, FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D),
- quiet = TRUE, cores = n_cores))
+ quiet = TRUE, cluster = cl))
# One metabolite
SFO_SFO <- mkinmod(parent = mkinsub("SFO", to = "m1"),
@@ -82,13 +88,14 @@ fit_tc_1 <- mkinfit(m_synth_SFO_lin, SFO_lin_a, error_model = "tc", quiet = TRUE
error_model_algorithm = "threestep")
# Mixed model fits
-mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc", cores = n_cores)
-mmkin_dfop_1 <- mmkin("DFOP", ds_dfop, quiet = TRUE, cores = n_cores,
+mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc", cluster = cl)
+mmkin_dfop_1 <- mmkin("DFOP", ds_dfop, quiet = TRUE, cluster = cl,
error_model = "tc")
DFOP_SFO <- mkinmod(parent = mkinsub("DFOP", "m1"),
m1 = mkinsub("SFO"), quiet = TRUE)
-mmkin_dfop_sfo <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_dfop_sfo, quiet = TRUE, cores = n_cores,
+mmkin_dfop_sfo <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_dfop_sfo, quiet = TRUE,
+ cluster = cl,
control = list(eval.max = 500, iter.max = 400),
error_model = "tc")
@@ -105,3 +112,4 @@ dfop_saem_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin",
saem_dfop_sfo_m <- saem(mmkin_dfop_sfo, transformations = "mkin", quiet = TRUE)
saem_dfop_sfo_s <- saem(mmkin_dfop_sfo, transformations = "saemix", quiet = TRUE)
+parallel::stopCluster(cl)
diff --git a/tests/testthat/test_saemix_parent.R b/tests/testthat/test_saemix_parent.R
index 31605931..7fbecd0c 100644
--- a/tests/testthat/test_saemix_parent.R
+++ b/tests/testthat/test_saemix_parent.R
@@ -15,7 +15,7 @@ test_that("Parent fits using saemix are correctly implemented", {
expect_silent(print(illparms(sfo_saem_1_reduced)))
# We cannot currently do the fit with completely fixed initial values
- mmkin_sfo_2 <- update(mmkin_sfo_1, fixed_initials = c(parent = 100))
+ mmkin_sfo_2 <- update(mmkin_sfo_1, fixed_initials = c(parent = 100), cluster = NULL, cores = n_cores)
sfo_saem_3 <- expect_error(saem(mmkin_sfo_2, quiet = TRUE), "at least two parameters")
# We get an error if we do not supply a suitable model specification

Contact - Imprint