aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-05-11 05:15:19 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2020-05-11 05:18:32 +0200
commit234c9059a95e104917e488a6ddd2313234a96cdc (patch)
treef6e54098f79d94578434ef727b62f7cc5d5e79b7 /tests
parentd113cd79b178fdc91aecb894707ed356129dfb75 (diff)
Avoid merge() and data.frame() in cost function
also for deSolve and eigenvalue based solutions. This noticeably increases performance for these methods, see test.log and benchmark vignette.
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat/FOCUS_2006_D.csf2
-rw-r--r--tests/testthat/test_mkinpredict_SFO_SFO.R26
-rw-r--r--tests/testthat/test_plots_summary_twa.R2
3 files changed, 16 insertions, 14 deletions
diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf
index d41f0a9f..c0c5c10c 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-05-10
+Date: 2020-05-11
Optimiser: IRLS
[Data]
diff --git a/tests/testthat/test_mkinpredict_SFO_SFO.R b/tests/testthat/test_mkinpredict_SFO_SFO.R
index 347aa50b..d0dc7cdb 100644
--- a/tests/testthat/test_mkinpredict_SFO_SFO.R
+++ b/tests/testthat/test_mkinpredict_SFO_SFO.R
@@ -5,26 +5,28 @@ test_that("Variants of model predictions for SFO_SFO model give equivalent resul
# Do not use time 0, as eigenvalue based solution does not give 0 at time 0 for metabolites
# and relative tolerance is thus not met
tol = 0.01
- SFO_SFO.1 <- mkinmod(parent = list(type = "SFO", to = "m1"),
- m1 = list(type = "SFO"), use_of_ff = "min", quiet = TRUE)
- SFO_SFO.2 <- mkinmod(parent = list(type = "SFO", to = "m1"),
- m1 = list(type = "SFO"), use_of_ff = "max", quiet = TRUE)
+ SFO_SFO.1 <- mkinmod(parent = mkinsub("SFO", to = "m1"),
+ m1 = mkinsub("SFO"), use_of_ff = "min", quiet = TRUE)
+ SFO_SFO.2 <- mkinmod(parent = mkinsub("SFO", to = "m1"),
+ m1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE)
ot = seq(0, 100, by = 1)
- r.1.e <- subset(mkinpredict(SFO_SFO.1,
+ r.1.e <- subset(as.data.frame(mkinpredict(SFO_SFO.1,
c(k_parent_m1 = 0.1, k_parent_sink = 0.1, k_m1_sink = 0.1),
- c(parent = 100, m1 = 0), ot, solution_type = "eigen"),
+ c(parent = 100, m1 = 0), ot, solution_type = "eigen")),
time %in% c(1, 10, 50, 100))
- r.1.d <- subset(mkinpredict(SFO_SFO.1,
+ r.1.d <- subset(as.data.frame(mkinpredict(SFO_SFO.1,
c(k_parent_m1 = 0.1, k_parent_sink = 0.1, k_m1_sink = 0.1),
- c(parent = 100, m1 = 0), ot, solution_type = "deSolve"),
+ c(parent = 100, m1 = 0), ot, solution_type = "deSolve")),
time %in% c(1, 10, 50, 100))
- r.2.e <- subset(mkinpredict(SFO_SFO.2, c(k_parent = 0.2, f_parent_to_m1 = 0.5, k_m1 = 0.1),
- c(parent = 100, m1 = 0), ot, solution_type = "eigen"),
+ r.2.e <- subset(as.data.frame(mkinpredict(SFO_SFO.2,
+ c(k_parent = 0.2, f_parent_to_m1 = 0.5, k_m1 = 0.1),
+ c(parent = 100, m1 = 0), ot, solution_type = "eigen")),
time %in% c(1, 10, 50, 100))
- r.2.d <- subset(mkinpredict(SFO_SFO.2, c(k_parent = 0.2, f_parent_to_m1 = 0.5, k_m1 = 0.1),
- c(parent = 100, m1 = 0), ot, solution_type = "deSolve"),
+ r.2.d <- subset(as.data.frame(mkinpredict(SFO_SFO.2,
+ c(k_parent = 0.2, f_parent_to_m1 = 0.5, k_m1 = 0.1),
+ c(parent = 100, m1 = 0), ot, solution_type = "deSolve")),
time %in% c(1, 10, 50, 100))
# Compare eigen and deSolve for minimum use of formation fractions
diff --git a/tests/testthat/test_plots_summary_twa.R b/tests/testthat/test_plots_summary_twa.R
index 13d1dd0f..bc3d29a8 100644
--- a/tests/testthat/test_plots_summary_twa.R
+++ b/tests/testthat/test_plots_summary_twa.R
@@ -13,7 +13,7 @@ test_that("Time weighted average concentrations are correct", {
odeparms = bpar[2:length(bpar)],
odeini = c(parent = bpar[[1]]),
outtimes = outtimes_10)
- twa_num <- mean(pred_10$parent)
+ twa_num <- mean(pred_10[, "parent"])
names(twa_num) <- 10
twa_ana <- max_twa_parent(fit, 10)

Contact - Imprint