aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2015-05-15 11:02:19 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2015-05-15 11:03:16 +0200
commitfbf43bbfd6e7ed265fea1cfd0e6b0004dbb6cde2 (patch)
tree9c6e31e58b0c6bc62ee7fd476d2cbc5e94923125 /tests
parent9bb55ca2a59c8ce7d3b1069eec7a8aaf57e61df0 (diff)
Also migrate test for mkinpredict
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat/test_mkinpredict_SFO_SFO.R (renamed from tests/testthat/runit.mkinpredict.R)40
1 files changed, 12 insertions, 28 deletions
diff --git a/tests/testthat/runit.mkinpredict.R b/tests/testthat/test_mkinpredict_SFO_SFO.R
index 997857ce..1238bb28 100644
--- a/tests/testthat/runit.mkinpredict.R
+++ b/tests/testthat/test_mkinpredict_SFO_SFO.R
@@ -1,6 +1,6 @@
# $Id: jranke $
-# Copyright (C) 2012 Johannes Ranke
+# Copyright (C) 2012-2015 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -18,28 +18,14 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>
-# Check solution types for SFO {{{
-test.SFO_solution_types <- function()
-{
- ot = seq(0, 100, by = 1)
- SFO <- mkinmod(parent = list(type = "SFO"))
- SFO.analytical <- round(subset(mkinpredict(SFO, c(k_parent_sink = 0.1),
- c(parent = 100), ot, solution_type = "analytical"), time == 100), digits=5)
- SFO.deSolve <- round(subset(mkinpredict(SFO, c(k_parent_sink = 0.1),
- c(parent = 100), ot, solution_type = "deSolve"), time == 100), digits=5)
- SFO.eigen <- round(subset(mkinpredict(SFO, c(k_parent_sink = 0.1),
- c(parent = 100), ot, solution_type = "eigen"), time == 100), digits=5)
-
- checkEquals(SFO.analytical, SFO.deSolve)
- checkEquals(SFO.analytical, SFO.eigen)
-} # }}}
+# This was migrated from an RUnit test in inst/unitTests/runit.mkinpredict.R
-# Check model specification and solution types for SFO_SFO {{{
-# Relative Tolerance is 0.01%
-# 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
-test.SFO_solution_types <- function()
-{
+context("Model predictions with mkinpredict")
+test_that("Variants of model predictions for SFO_SFO model give equivalent results", {
+ # Check model specification and solution types for SFO_SFO
+ # Relative Tolerance is 0.01%
+ # 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")
@@ -67,20 +53,18 @@ test.SFO_solution_types <- function()
dev.1.e_d.percent = 100 * (r.1.e[-1] - r.1.d[-1])/r.1.e[-1]
dev.1.e_d.percent = as.numeric(unlist((dev.1.e_d.percent)))
dev.1.e_d.percent = ifelse(is.na(dev.1.e_d.percent), 0, dev.1.e_d.percent)
- checkIdentical(dev.1.e_d.percent < tol, rep(TRUE, length(dev.1.e_d.percent)))
+ expect_equivalent(dev.1.e_d.percent < tol, rep(TRUE, length(dev.1.e_d.percent)))
# Compare eigen and deSolve for maximum use of formation fractions
dev.2.e_d.percent = 100 * (r.1.e[-1] - r.1.d[-1])/r.1.e[-1]
dev.2.e_d.percent = as.numeric(unlist((dev.2.e_d.percent)))
dev.2.e_d.percent = ifelse(is.na(dev.2.e_d.percent), 0, dev.2.e_d.percent)
- checkIdentical(dev.2.e_d.percent < tol, rep(TRUE, length(dev.2.e_d.percent)))
+ expect_equivalent(dev.2.e_d.percent < tol, rep(TRUE, length(dev.2.e_d.percent)))
# Compare minimum and maximum use of formation fractions
dev.1_2.e.percent = 100 * (r.1.e[-1] - r.2.e[-1])/r.1.e[-1]
dev.1_2.e.percent = as.numeric(unlist((dev.1_2.e.percent)))
dev.1_2.e.percent = ifelse(is.na(dev.1_2.e.percent), 0, dev.1_2.e.percent)
- checkIdentical(dev.1_2.e.percent < tol, rep(TRUE, length(dev.1_2.e.percent)))
-
-} # }}}
+ expect_equivalent(dev.1_2.e.percent < tol, rep(TRUE, length(dev.1_2.e.percent)))
-# vim: set foldmethod=marker ts=2 sw=2 expandtab:
+})

Contact - Imprint