diff options
| author | Ranke Johannes <johannes.ranke@agroscope.admin.ch> | 2026-09-07 13:45:39 +0200 |
|---|---|---|
| committer | Ranke Johannes <johannes.ranke@agroscope.admin.ch> | 2026-09-07 13:45:39 +0200 |
| commit | 48d9cad339394c3aa0d730d9a27b1c0680ce13e8 (patch) | |
| tree | 9c0a5766f3d0853c382ba0174f83e2e8ac9b0fbf /tests/testthat/test_endpoints.R | |
| parent | 46735d7a6d429bb0c50f951763797f321a0d77ca (diff) | |
The tolerance of one test had to be increased in test_deSolve.R,
and four vdiffr snapshots with negligible differences were updated.
Tests run with a maximum of 16 cores when running in the Agroscope
Apptainer environment.
Diffstat (limited to 'tests/testthat/test_endpoints.R')
| -rw-r--r-- | tests/testthat/test_endpoints.R | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/testthat/test_endpoints.R b/tests/testthat/test_endpoints.R new file mode 100644 index 00000000..284e1379 --- /dev/null +++ b/tests/testthat/test_endpoints.R @@ -0,0 +1,49 @@ +context("DTx calculations") + +test_that("The DTx function gives the same results as the endpoints function", { + # We silently assume that the calculations in the endpoint function are correct + + SFO_fit <- fits[["SFO", "FOCUS_C"]] + SFO_distimes <- endpoints(SFO_fit)$distimes + SFO_DTx <- DTx("SFO", c(k = parms(SFO_fit)[["k_parent"]])) + + expect_equal( + as.numeric(SFO_distimes), + as.numeric(SFO_DTx) + ) + + FOMC_fit <- fits[["FOMC", "FOCUS_C"]] + FOMC_distimes <- endpoints(FOMC_fit)$distimes + FOMC_DTx <- DTx("FOMC", c( + alpha = parms(FOMC_fit)[["alpha"]], + beta = parms(FOMC_fit)[["beta"]]), exact = TRUE) + + expect_equal( + as.numeric(FOMC_distimes), + as.numeric(FOMC_DTx) + ) + + DFOP_fit <- fits[["DFOP", "FOCUS_C"]] + DFOP_distimes <- endpoints(DFOP_fit)$distimes + DFOP_DTx <- DTx("DFOP", c( + k1 = parms(DFOP_fit)[["k1"]], + k2 = parms(DFOP_fit)[["k2"]], + g = parms(DFOP_fit)[["g"]]), exact = TRUE) + + expect_equal( + as.numeric(DFOP_distimes), + as.numeric(DFOP_DTx) + ) + + HS_fit <- fits[["HS", "FOCUS_C"]] + HS_distimes <- endpoints(HS_fit)$distimes + HS_DTx <- DTx("HS", c( + k1 = parms(HS_fit)[["k1"]], + k2 = parms(HS_fit)[["k2"]], + tb = parms(HS_fit)[["tb"]]), exact = TRUE) + + expect_equal( + as.numeric(HS_distimes), + as.numeric(HS_DTx) + ) +}) |
