Skip to content
Snippets Groups Projects
Commit 4f5cd640 authored by Sebastian Henz's avatar Sebastian Henz
Browse files

Improve tests

decrease number of tests and decrease equality test tolerance
closes #16
parent 0a70d95a
No related branches found
No related tags found
1 merge request!3V2.0
......@@ -92,112 +92,81 @@ test_that("min(concentration) > 0 is conserved", {
test_that("the discrete results have not changed", {
expect_equal(
round(mod$effect_tox_simple, 3),
c(85.000, 84.542, 78.946, 31.959, 2.610)
mod$effect_tox_simple,
c(85, 84.542019, 78.946417, 31.958587, 2.609627),
tolerance = 1e-7
)
expect_equal(
round(mod$effect_tox, 3),
c(100.000, 99.676, 94.320, 34.860, 0.840)
mod$effect_tox,
c(100, 99.6760075, 94.3197537, 34.8601868, 0.8400338),
tolerance = 1e-7
)
expect_equal(
round(mod$stress_tox, 3),
c(0.000, 0.078, 0.207, 0.579, 0.893)
mod$stress_tox,
c(0, 0.07839514, 0.20674901, 0.57943794, 0.89269358),
tolerance = 1e-7
)
expect_equal(
round(mod$sys_stress_tox, 3),
c(0.296, 0.280, 0.000, 0.000, 0.000)
mod$sys_stress_tox,
c(0.2964507, 0.2795151, 0, 0, 0),
tolerance = 1e-7
)
expect_equal(
round(mod$effect_tox_sys, 3),
c(84.791, 77.481, 93.138, 34.86, 0.84)
mod$effect_tox_sys,
c(84.7911701, 77.4810863, 93.1380038, 34.8601868, 0.8400338),
tolerance = 1e-7
)
expect_equal(round(mod$stress_env, 3), 0.388)
expect_equal(mod$stress_env, 0.3884627, tolerance = 1e-7)
expect_equal(
round(mod$effect_tox_env_simple, 3),
c(26.333, 26.333, 26.062, 0.710, 0.037)
mod$effect_tox_env_simple,
c(26.33333333, 26.33332818, 26.06197358, 0.71041187, 0.03744973),
tolerance = 1e-7
)
expect_equal(
round(mod$stress_tox_env, 3),
c(0.388, 0.467, 0.595, 0.968, 1.281)
mod$stress_tox_env,
c(0.3884627, 0.4668578, 0.5952117, 0.9679006, 1.2811562),
tolerance = 1e-7
)
expect_equal(
round(mod$effect_tox_env, 3),
c(70.879, 56.414, 32.000, 0.020, 0.000)
mod$effect_tox_env,
c(70.87862236, 56.41378553, 32, 0.02016827, 0),
tolerance = 1e-7
)
expect_equal(
round(mod$sys_stress_tox_env, 3),
c(0.254, 0.181, 0.000, 0.000, 0.000)
mod$sys_stress_tox_env,
c(0.2536271, 0.1814848, 0, 0, 0),
tolerance = 1e-7
)
expect_equal(
round(mod$effect_tox_env_sys, 3),
c(24.325, 22.323, 29.386, 0.020, 0.000)
mod$effect_tox_env_sys,
c(24.3253712, 22.32323664, 29.38593058, 0.02016827, 0),
tolerance = 1e-7
)
})
test_that("the smooth curves have not changed", {
curves <- mod$curves
i <- c(1, 714, 810, 905, 1000)
expect_equal(
round(curves$concentration[i], 3),
c(0.000, 0.014, 0.125, 1.120, 10.000)
)
expect_equal(
round(curves$effect_tox_simple[i], 3),
c(85.000, 84.812, 82.700, 61.288, 2.610)
)
expect_equal(
round(curves$effect_tox[i], 3),
c(100.000, 99.879, 98.064, 73.665, 0.840)
)
expect_equal(
round(curves$effect_tox_sys[i], 3),
c(84.780, 77.932, 87.580, 73.665, 0.840)
)
expect_equal(
round(curves$stress_tox[i], 3),
c(0.000, 0.057, 0.142, 0.372, 0.893)
)
expect_equal(
round(curves$sys_stress_tox[i], 3),
c(0.298, 0.289, 0.134, 0.000, 0.000)
)
expect_equal(
round(curves$stress_tox_sys[i], 3),
c(0.298, 0.346, 0.276, 0.372, 0.893)
)
expect_equal(
round(curves$effect_tox_env[i], 3),
c(70.863, 60.496, 44.083, 8.514, 0)
)
expect_equal(
round(curves$effect_tox_env_sys[i], 3),
c(24.311, 20.727, 29.948, 8.513, 0.000)
)
expect_equal(
round(curves$stress_env[i], 3),
c(0.388, 0.388, 0.388, 0.388, 0.388)
)
expect_equal(
round(curves$effect_tox_env_simple[i], 3),
c(26.333, 26.333, 26.329, 7.538, 0.037)
)
expect_equal(
round(curves$stress_tox_env[i], 3),
c(0.389, 0.445, 0.531, 0.761, 1.281)
)
expect_equal(
round(curves$sys_stress_tox_env[i], 3),
c(0.252, 0.218, 0.076, 0.000, 0.000)
)
expect_equal(
round(curves$stress_tox_env_sys[i], 3),
c(0.640, 0.663, 0.607, 0.761, 1.281)
)
expect_equal(
curves$use_for_plotting[i],
c(TRUE, TRUE, TRUE, TRUE, TRUE)
)
test_that("the curves have not changed", {
new_curves <- mod$curves[c(1, 714, 810, 905, 1000), ] # random indices
rownames(new_curves) <- NULL
reference_curves <- data.frame(
concentration = c(1e-09, 0.01371315, 0.12534243, 1.119564319, 10),
effect_tox_simple = c(85, 84.81163377, 82.69957233, 61.288248213, 2.6096274),
effect_tox = c(100, 99.87865109, 98.06445677, 73.665157983, 0.84003381),
effect_tox_sys = c(84.77969, 77.93231294, 87.5798928, 73.665157982, 0.84003381),
stress_tox = c(8.749e-05, 0.05700307, 0.14209575, 0.372116727, 0.89269358),
sys_stress_tox = c(0.2980476, 0.2887223, 0.13361978, 0, 0),
stress_tox_sys = c(0.2981351, 0.34572536, 0.27571552, 0.372116727, 0.89269358),
effect_tox_env_simple = c(26.33333, 26.33333321, 26.32888625, 7.538424311, 0.03744973),
effect_tox_env = c(70.86344, 60.49574096, 44.08337933, 8.513734057, 0),
effect_tox_env_sys = c(24.31118, 20.72721748, 29.9481253, 8.513316482, 0),
stress_env = c(0.3884627, 0.38846267, 0.38846267, 0.388462669, 0.38846267),
stress_tox_env = c(0.3885502, 0.44546574, 0.53055841, 0.760579395, 1.28115624),
sys_stress_tox_env = c(0.2516156, 0.2175288, 0.07623744, 4.319e-06, 0),
stress_tox_env_sys = c(0.6401658, 0.66299453, 0.60679585, 0.760583715, 1.28115624),
use_for_plotting = c(TRUE, TRUE, TRUE, TRUE, TRUE)
)
class(new_curves) <- class(reference_curves)
expect_equal(new_curves, reference_curves, tolerance = 1e-7)
})
......@@ -210,13 +179,16 @@ test_that("the returned fn works the same way as internally", {
test_that("function arguments are returned unchanged", {
expect_equal(mod$args$effect_tox_observed, c(85, 76, 94, 35, 0))
expect_equal(mod$args$effect_tox_env_observed, c(24, 23, 32, 0, 0))
expect_equal(mod$args$concentration, c(0, 0.03, 0.3, 3, 10))
expect_equal(mod$args$hormesis_concentration, 0.3)
expect_equal(mod$args$effect_max, 100)
expect_equal(mod$args$p, 3.2)
expect_equal(mod$args$q, 3.2)
args_reference <- list(
concentration = c(0, 0.03, 0.3, 3, 10),
hormesis_concentration = 0.3,
effect_tox_observed = c(85, 76, 94, 35, 0),
effect_tox_env_observed = c(24, 23, 32, 0, 0),
effect_max = 100,
p = 3.2,
q = 3.2
)
expect_identical(args_reference, mod$args)
})
......
  • Author Owner

    Error in commit message: This actually increases, not decreases the tolerance.

    Edited by Sebastian Henz
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment