From 0d8521f3f60082f0fd27da00a7ac8bcef9ee5ba0 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 26 Oct 2022 00:57:40 +0200 Subject: Make multistart work with testthat scopes Also skip long-running test with saem using the analytical from mkin --- .../multistart/llhist-for-biphasic-saemix-fit.svg | 61 +++++++ .../multistart/parhist-for-biphasic-saemix-fit.svg | 196 +++++++++++++++++++++ tests/testthat/test_mixed.R | 1 - tests/testthat/test_multistart.R | 4 +- tests/testthat/test_saemix_parent.R | 2 +- 5 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 tests/testthat/_snaps/multistart/llhist-for-biphasic-saemix-fit.svg create mode 100644 tests/testthat/_snaps/multistart/parhist-for-biphasic-saemix-fit.svg (limited to 'tests/testthat') diff --git a/tests/testthat/_snaps/multistart/llhist-for-biphasic-saemix-fit.svg b/tests/testthat/_snaps/multistart/llhist-for-biphasic-saemix-fit.svg new file mode 100644 index 00000000..154eb60d --- /dev/null +++ b/tests/testthat/_snaps/multistart/llhist-for-biphasic-saemix-fit.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + +Frequency of log likelihoods + + + + + + + +-1190 +-1185 +-1180 +-1175 +-1170 +-1165 + + + + +0 +1 +2 + + + + + + + + + + + + + + + + +original log likelihood +kernel density estimate + + diff --git a/tests/testthat/_snaps/multistart/parhist-for-biphasic-saemix-fit.svg b/tests/testthat/_snaps/multistart/parhist-for-biphasic-saemix-fit.svg new file mode 100644 index 00000000..aa2bc3d4 --- /dev/null +++ b/tests/testthat/_snaps/multistart/parhist-for-biphasic-saemix-fit.svg @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +parent_0 +f_parent_to_m1 +k2 +g +a.1 +b.1 +SD.log_k_m1 +SD.log_k1 +SD.g_qlogis + + + + + +0.5 +1.0 +1.5 +2.0 +Normalised parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Starting parameters +Original run +Multistart runs + + diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R index de030199..e005c982 100644 --- a/tests/testthat/test_mixed.R +++ b/tests/testthat/test_mixed.R @@ -24,7 +24,6 @@ test_that("nlme results are reproducible to some degree", { test_summary$date.summary <- "Dummy date for testing" test_summary$time <- c(elapsed = "test time 0") - print(test_summary, digits = 1) expect_known_output(print(test_summary, digits = 1), "summary_dfop_nlme_1.txt") # The biphasic example data illustrate that DFOP parameters are difficult to diff --git a/tests/testthat/test_multistart.R b/tests/testthat/test_multistart.R index 04f08aa7..e0b1ecd7 100644 --- a/tests/testthat/test_multistart.R +++ b/tests/testthat/test_multistart.R @@ -1,4 +1,6 @@ -test_that("multistart works for saem.mmix models", { +context("Multistart method for saem.mmkin models") + +test_that("multistart works for saem.mmkin models", { saem_biphasic_m_multi <- multistart(saem_biphasic_m, n = 8, cores = n_cores) expect_known_output(print(saem_biphasic_m_multi), diff --git a/tests/testthat/test_saemix_parent.R b/tests/testthat/test_saemix_parent.R index 4504e573..d8b6b19e 100644 --- a/tests/testthat/test_saemix_parent.R +++ b/tests/testthat/test_saemix_parent.R @@ -140,7 +140,7 @@ test_that("We can also use mkin solution methods for saem", { expect_error(saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix", solution_type = "analytical"), "saemix transformations is only supported if an analytical solution is implemented" ) - skip_on_cran() # This still takes almost 2.5 minutes although we do not solve ODEs + skip("This still takes almost 2.5 minutes although we do not solve ODEs") dfop_saemix_3 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin", solution_type = "analytical", no_random_effect = "parent_0") distimes_dfop <- endpoints(dfop_saemix_1)$distimes -- cgit v1.2.1