aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-02-26 09:12:50 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2019-02-26 09:12:50 +0100
commit6693ee373c61d716e877386d6be16e3f9f0f40ab (patch)
tree7e1e8607c96b459878ca81e9b183795399aeb516 /tests/testthat
parent885ea2cd3392e57efff72e5094643917d6ba2be8 (diff)
Add another NAFTA dataset + test
Diffstat (limited to 'tests/testthat')
-rw-r--r--tests/testthat/FOCUS_2006_D.csf2
-rw-r--r--tests/testthat/NAFTA_SOP_Appendix_B.txt35
-rw-r--r--tests/testthat/NAFTA_SOP_Appendix_D.txt (renamed from tests/testthat/print_nafta_analysis.txt)2
-rw-r--r--tests/testthat/test_CAKE_export.R22
-rw-r--r--tests/testthat/test_nafta.R28
5 files changed, 62 insertions, 27 deletions
diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf
index d695e90d..22c5f2b4 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: 2019-02-25
+Date: 2019-02-26
Optimiser: IRLS
[Data]
diff --git a/tests/testthat/NAFTA_SOP_Appendix_B.txt b/tests/testthat/NAFTA_SOP_Appendix_B.txt
new file mode 100644
index 00000000..54b70880
--- /dev/null
+++ b/tests/testthat/NAFTA_SOP_Appendix_B.txt
@@ -0,0 +1,35 @@
+Sums of squares:
+ SFO IORE DFOP
+174.39718 21.91831 16.57180
+
+Critical sum of squares for checking the SFO model:
+[1] 26.93798
+
+Parameters:
+$SFO
+ Estimate Pr(>t) Lower Upper
+parent_0 51.2430312 1.178492e-10 45.4036817 57.0823806
+k_parent_sink 0.2531291 1.608492e-06 0.1935733 0.3310082
+
+$IORE
+ Estimate Pr(>t) Lower Upper
+parent_0 51.71052958 8.522722e-15 4.951371e+01 53.907348315
+k__iore_parent_sink 0.00134836 6.841092e-02 3.421381e-04 0.005313861
+N_parent 2.66146927 3.975823e-08 2.191012e+00 3.131926902
+
+$DFOP
+ Estimate Pr(>t) Lower Upper
+parent_0 51.70546719 3.457982e-14 49.677926850 53.73300753
+k1 0.41569648 1.002119e-06 0.330769606 0.52242879
+k2 0.01273299 1.393989e-03 0.007230162 0.02242399
+g 0.83380396 5.718367e-12 0.771816175 0.88153694
+
+
+DTx values:
+ DT50 DT90 DT50_rep
+SFO 3 9 3
+IORE 1 28 9
+DFOP 2 40 54
+
+Representative half-life:
+[1] 8.573301
diff --git a/tests/testthat/print_nafta_analysis.txt b/tests/testthat/NAFTA_SOP_Appendix_D.txt
index 61d2539f..d01accf2 100644
--- a/tests/testthat/print_nafta_analysis.txt
+++ b/tests/testthat/NAFTA_SOP_Appendix_D.txt
@@ -1,6 +1,8 @@
Sums of squares:
SFO IORE DFOP
1378.6832 615.7730 517.8836
+
+Critical sum of squares for checking the SFO model:
[1] 717.4598
Parameters:
diff --git a/tests/testthat/test_CAKE_export.R b/tests/testthat/test_CAKE_export.R
index aeb192c8..5f984782 100644
--- a/tests/testthat/test_CAKE_export.R
+++ b/tests/testthat/test_CAKE_export.R
@@ -27,25 +27,3 @@ test_that("Exporting is reproducible", {
csf <- readLines(con = "FOCUS_2006_D.csf")
expect_known_output(csf, "FOCUS_2006_D.txt")
})
-
-test_that("Test data from Appendix D are correctly evaluated", {
- expect_message(res <- nafta(MRID_555555, "MRID 555555"))
-
- # From Figure D.1
- dtx_sop <- matrix(c(407, 541, 429, 1352, 5192066, 2383), nrow = 3, ncol = 2)
- expect_equivalent(res$distimes[, 1:2], dtx_sop, tolerance = 1,
- scale = 1)
-
- C0_sop <- c(SFO = 83.8, IORE = 96.9, DFOP = 97.6)
- C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"])
- expect_equivalent(C0_mkin, C0_sop, scale = 1, tolerance = 0.1)
-
- expect_equal(round(res$S_c), 717)
- expect_equal(signif(res$S[["SFO"]], 3), 1.38e+3)
- expect_equal(round(res$t_rep), 841)
-
- expect_known_output(print(res), "print_nafta_analysis.txt")
-
- plot_nafta <- function() plot(res)
- vdiffr::expect_doppelganger("Plot NAFTA analysis", plot_nafta)
-})
diff --git a/tests/testthat/test_nafta.R b/tests/testthat/test_nafta.R
index 10de3ce0..a50d8f36 100644
--- a/tests/testthat/test_nafta.R
+++ b/tests/testthat/test_nafta.R
@@ -21,13 +21,33 @@ context("Evaluations according to 2015 NAFTA guidance")
test_that("Data for more than one compound are rejected",
expect_error(nafta(FOCUS_2006_D)))
+test_that("Test data from Appendix B are correctly evaluated", {
+ expect_message(res <- nafta(NAFTA_SOP_Appendix_B, "aerobic aquatic"))
+
+ # From Figure D.1
+ dtx_sop <- matrix(c(2.74, 1.37, 2.17, 9.1, 28.5, 39.9), nrow = 3, ncol = 2)
+ expect_equivalent(signif(res$distimes[, 1:2], 3), dtx_sop)
+
+ C0_sop <- c(SFO = 51.2, IORE = 51.7, DFOP = 51.7)
+ C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"])
+ expect_equivalent(C0_mkin, C0_sop, scale = 1, tolerance = 0.1)
+
+ expect_equal(signif(res$S_c, 3), 26.9)
+ expect_equal(signif(res$S[["SFO"]], 3), 174)
+ expect_equal(signif(res$t_rep, 3), 8.57)
+
+ expect_known_output(print(res), "NAFTA_SOP_Appendix_B.txt")
+
+ plot_nafta <- function() plot(res)
+ vdiffr::expect_doppelganger("NAFTA SOP Appendix B", plot_nafta)
+})
+
test_that("Test data from Appendix D are correctly evaluated", {
- expect_message(res <- nafta(MRID_555555, "MRID 555555"))
+ expect_message(res <- nafta(NAFTA_SOP_Appendix_D, "MRID 555555"))
# From Figure D.1
dtx_sop <- matrix(c(407, 541, 429, 1352, 5192066, 2383), nrow = 3, ncol = 2)
- expect_equivalent(res$distimes[, 1:2], dtx_sop, tolerance = 1,
- scale = 1)
+ expect_equivalent(round(res$distimes[, 1:2]), dtx_sop)
C0_sop <- c(SFO = 83.8, IORE = 96.9, DFOP = 97.6)
C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"])
@@ -37,7 +57,7 @@ test_that("Test data from Appendix D are correctly evaluated", {
expect_equal(signif(res$S[["SFO"]], 3), 1.38e+3)
expect_equal(round(res$t_rep), 841)
- expect_known_output(print(res), "print_nafta_analysis.txt")
+ expect_known_output(print(res), "NAFTA_SOP_Appendix_D.txt")
plot_nafta <- function() plot(res)
vdiffr::expect_doppelganger("Plot NAFTA analysis", plot_nafta)

Contact - Imprint