From cd6c050150a344b5371951f8fa389b0a586f4fab Mon Sep 17 00:00:00 2001 From: Phi-S <926151+Phi-S@users.noreply.github.com> Date: Sun, 15 Feb 2026 07:58:56 +0100 Subject: [PATCH 1/2] before rename --- .../testthat/test-combo_plot_control_etr_I.R | 32 +++---- .../testthat/test-combo_plot_control_etr_II.R | 33 ++++---- .../test-compare_regression_models_etr_I.R | 33 +++----- .../test-compare_regression_models_etr_II.R | 34 +++----- .../test-compare_regression_models_total.R | 84 ++++++++----------- .../testthat/test-eilers_peeters_etr_I.R | 73 +++++----------- .../testthat/test-eilers_peeters_etr_II.R | 63 ++++---------- .../test-eilers_peeters_etr_II_junior_pam.R | 63 ++++---------- .../test-get_etr_data_for_par_values.R | 2 +- src/tests/testthat/test-platt_etr_I.R | 62 ++++---------- src/tests/testthat/test-platt_etr_II.R | 70 +++++----------- src/tests/testthat/test-read_dual_pam_data.R | 21 +++-- .../testthat/test-read_junior_pam_data.R | 19 +++-- src/tests/testthat/test-read_universal_data.R | 19 +++-- .../test-relative_root_mean_squared_error.R | 8 +- .../testthat/test-root_mean_squared_error.R | 9 +- .../testthat/test-universal_data_etr_I.R | 72 +--------------- src/tests/testthat/test-vollenweider_etr_I.R | 70 +++++----------- src/tests/testthat/test-vollenweider_etr_II.R | 70 +++++----------- src/tests/testthat/test-walsby_etr_I.R | 65 +++++--------- src/tests/testthat/test-walsby_etr_II.R | 64 +++++--------- .../testthat/test-write_model_result_csv.R | 26 +++--- 22 files changed, 314 insertions(+), 678 deletions(-) diff --git a/src/tests/testthat/test-combo_plot_control_etr_I.R b/src/tests/testthat/test-combo_plot_control_etr_I.R index f1c2056..22da1c9 100644 --- a/src/tests/testthat/test-combo_plot_control_etr_I.R +++ b/src/tests/testthat/test-combo_plot_control_etr_I.R @@ -1,22 +1,24 @@ test_that("test-combo_plot_control 20240925.csv", { test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) - expect_no_error({ - data <- read_dual_pam_data(test_data_file) + eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) + platt <- platt_modified(platt_generate_regression_ETR_I(data)) + walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) + vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) - eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) - platt <- platt_modified(platt_generate_regression_ETR_I(data)) - walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) - vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) + plot <- combo_plot_control( + "etr I test-combo_plot_control_20240925.csv", + data, + list(eilers_peeters, platt, walsby, vollenweider), + list("eilers_peeters", "platt", "walsby", "vollenweider"), + list(color_eilers_peeters, color_platt, color_walsby, color_vollenweider) + ) - plot <- combo_plot_control( - "etr I test-combo_plot_control_20240925.csv", - data, - list(eilers_peeters, platt, walsby, vollenweider), - list("eilers_peeters", "platt", "walsby", "vollenweider"), - list(color_eilers_peeters, color_platt, color_walsby, color_vollenweider) - ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - ggplot2::ggsave("results/test_combo_plot_control_etr_I.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 2100, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test_combo_plot_control_etr_I.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 2100, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-combo_plot_control_etr_II.R b/src/tests/testthat/test-combo_plot_control_etr_II.R index 8a96876..8db85bc 100644 --- a/src/tests/testthat/test-combo_plot_control_etr_II.R +++ b/src/tests/testthat/test-combo_plot_control_etr_II.R @@ -1,22 +1,23 @@ test_that("test-combo_plot_control 20240925.csv", { test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) - expect_no_error({ - data <- read_dual_pam_data(test_data_file) + eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_II(data)) + platt <- platt_modified(platt_generate_regression_ETR_II(data)) + walsby <- walsby_modified(walsby_generate_regression_ETR_II(data)) + vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_II(data)) - eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_II(data)) - platt <- platt_modified(platt_generate_regression_ETR_II(data)) - walsby <- walsby_modified(walsby_generate_regression_ETR_II(data)) - vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_II(data)) + plot <- combo_plot_control( + "etr II test-combo_plot_control_20240925.csv", + data, + list(eilers_peeters, platt, walsby, vollenweider), + list("eilers_peeters", "platt", "walsby", "vollenweider"), + list(color_eilers_peeters, color_platt, color_walsby, color_vollenweider) + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- combo_plot_control( - "etr II test-combo_plot_control_20240925.csv", - data, - list(eilers_peeters, platt, walsby, vollenweider), - list("eilers_peeters", "platt", "walsby", "vollenweider"), - list(color_eilers_peeters, color_platt, color_walsby, color_vollenweider) - ) - - ggplot2::ggsave("results/test_combo_plot_control_etr_II.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 2100, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test_combo_plot_control_etr_II.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 2100, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-compare_regression_models_etr_I.R b/src/tests/testthat/test-compare_regression_models_etr_I.R index 7bc1eff..8150dfd 100644 --- a/src/tests/testthat/test-compare_regression_models_etr_I.R +++ b/src/tests/testthat/test-compare_regression_models_etr_I.R @@ -1,25 +1,16 @@ -test_that("compare_regression_models etr I", { +test_that("compare_regression_models etr I - linux", { + skip_if_not(is_debian_or_ubuntu()) test_data_dir <- file.path(getwd(), "data", "bulk") + model_points_etr_1 <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_equal(model_points_etr_I[["eilers_peeters"]], 13) + expect_equal(model_points_etr_I[["platt"]], 19) + expect_equal(model_points_etr_I[["vollenweider"]], 33) + expect_equal(model_points_etr_I[["walsby"]], 25) +}) - if (is_debian_or_ubuntu()) { - expect_no_error({ - model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) - }) - expect_equal(model_points_etr_I[["eilers_peeters"]], 13) - expect_equal(model_points_etr_I[["platt"]], 19) - expect_equal(model_points_etr_I[["vollenweider"]], 33) - expect_equal(model_points_etr_I[["walsby"]], 25) - } else if (is_windows()) { - expect_no_error({ - model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) - }) - expect_equal(model_points_etr_I[["eilers_peeters"]], 13) - expect_equal(model_points_etr_I[["platt"]], 19) - expect_equal(model_points_etr_I[["vollenweider"]], 33) - expect_equal(model_points_etr_I[["walsby"]], 25) - } +test_that("compare_regression_models etr I", { + test_data_dir <- file.path(getwd(), "data", "bulk") + model_points_etr_1 <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) + expect_named(result, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) }) diff --git a/src/tests/testthat/test-compare_regression_models_etr_II.R b/src/tests/testthat/test-compare_regression_models_etr_II.R index 0308a71..fdb980f 100644 --- a/src/tests/testthat/test-compare_regression_models_etr_II.R +++ b/src/tests/testthat/test-compare_regression_models_etr_II.R @@ -1,25 +1,17 @@ -test_that("compare_regression_models etr II", { +test_that("compare_regression_models etr II - linux", { + skip_if_not(is_debian_or_ubuntu()) + test_data_dir <- file.path(getwd(), "data", "bulk") + result <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_equal(result[["eilers_peeters"]], 37) + expect_equal(result[["platt"]], 20) + expect_equal(result[["vollenweider"]], 39) + expect_equal(result[["walsby"]], 6) +}) - if (is_debian_or_ubuntu()) { - expect_no_error({ - model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) - }) - expect_equal(model_points_etr_II[["eilers_peeters"]], 37) - expect_equal(model_points_etr_II[["platt"]], 20) - expect_equal(model_points_etr_II[["vollenweider"]], 39) - expect_equal(model_points_etr_II[["walsby"]], 6) - } else if (is_windows()) { - expect_no_error({ - model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) - }) - expect_equal(model_points_etr_II[["eilers_peeters"]], 37) - expect_equal(model_points_etr_II[["platt"]], 20) - expect_equal(model_points_etr_II[["vollenweider"]], 39) - expect_equal(model_points_etr_II[["walsby"]], 6) - } +test_that("compare_regression_models etr II", { + test_data_dir <- file.path(getwd(), "data", "bulk") + result <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) + expect_named(result, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) }) diff --git a/src/tests/testthat/test-compare_regression_models_total.R b/src/tests/testthat/test-compare_regression_models_total.R index 9eb2750..ce8285c 100644 --- a/src/tests/testthat/test-compare_regression_models_total.R +++ b/src/tests/testthat/test-compare_regression_models_total.R @@ -1,54 +1,38 @@ +test_that("compare_regression_models etr I + II - linux", { + skip_if_not(is_debian_or_ubuntu()) + test_data_dir <- file.path(getwd(), "data", "bulk") + model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) + model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) + + eilers_peeters_total <- model_points_etr_I[["eilers_peeters"]] + model_points_etr_II[["eilers_peeters"]] + platt_total <- model_points_etr_I[["platt"]] + model_points_etr_II[["platt"]] + vollenweider_total <- model_points_etr_I[["vollenweider"]] + model_points_etr_II[["vollenweider"]] + walsby_total <- model_points_etr_I[["walsby"]] + model_points_etr_II[["walsby"]] + + expect_equal(eilers_peeters_total, 50) + expect_equal(platt_total, 39) + expect_equal(vollenweider_total, 72) + expect_equal(walsby_total, 31) +}) + test_that("compare_regression_models etr I + II", { test_data_dir <- file.path(getwd(), "data", "bulk") - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } - - - if (is_debian_or_ubuntu()) { - expect_no_error({ - model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) - model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) - - eilers_peeters_total <- model_points_etr_I[["eilers_peeters"]] + model_points_etr_II[["eilers_peeters"]] - platt_total <- model_points_etr_I[["platt"]] + model_points_etr_II[["platt"]] - vollenweider_total <- model_points_etr_I[["vollenweider"]] + model_points_etr_II[["vollenweider"]] - walsby_total <- model_points_etr_I[["walsby"]] + model_points_etr_II[["walsby"]] - - result <- c( - eilers_peeters_total = eilers_peeters_total, - platt_total = platt_total, - vollenweider_total = vollenweider_total, - walsby_total = walsby_total - ) - }) - - expect_equal(result[["eilers_peeters_total"]], 50) - expect_equal(result[["platt_total"]], 39) - expect_equal(result[["vollenweider_total"]], 72) - expect_equal(result[["walsby_total"]], 31) - } else if (is_windows()) { - expect_no_error({ - model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) - model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) - - eilers_peeters_total <- model_points_etr_I[["eilers_peeters"]] + model_points_etr_II[["eilers_peeters"]] - platt_total <- model_points_etr_I[["platt"]] + model_points_etr_II[["platt"]] - vollenweider_total <- model_points_etr_I[["vollenweider"]] + model_points_etr_II[["vollenweider"]] - walsby_total <- model_points_etr_I[["walsby"]] + model_points_etr_II[["walsby"]] - - result <- c( - eilers_peeters_total = eilers_peeters_total, - platt_total = platt_total, - vollenweider_total = vollenweider_total, - walsby_total = walsby_total - ) - }) - - expect_equal(result[["eilers_peeters_total"]], 50) - expect_equal(result[["platt_total"]], 39) - expect_equal(result[["vollenweider_total"]], 72) - expect_equal(result[["walsby_total"]], 31) - } + model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) + expect_named(model_points_etr_I, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) + + model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) + expect_named(model_points_etr_II, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) + + eilers_peeters_total <- model_points_etr_I[["eilers_peeters"]] + model_points_etr_II[["eilers_peeters"]] + expect_true(eilers_peeters_total >= 0) + + platt_total <- model_points_etr_I[["platt"]] + model_points_etr_II[["platt"]] + expect_true(platt_total >= 0) + + vollenweider_total <- model_points_etr_I[["vollenweider"]] + model_points_etr_II[["vollenweider"]] + expect_true(vollenweider_total >= 0) + + walsby_total <- model_points_etr_I[["walsby"]] + model_points_etr_II[["walsby"]] + expect_true(walsby_total >= 0) }) diff --git a/src/tests/testthat/test-eilers_peeters_etr_I.R b/src/tests/testthat/test-eilers_peeters_etr_I.R index 4e63f6d..c693ec3 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_I.R +++ b/src/tests/testthat/test-eilers_peeters_etr_I.R @@ -1,11 +1,9 @@ test_that("test-eilers_peeters_etr_I generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) @@ -17,25 +15,15 @@ test_that("test-eilers_peeters_etr_I generate regression 20240925.csv", { expect_equal(model_result[["ik"]], 440.1289906) expect_equal(model_result[["im"]], 1399.769662) expect_equal(model_result[["w"]], 1.18036237) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) - # expect_equal(model_result[["a"]], 0.000001479) - # expect_equal(model_result[["b"]], 0.002444096) - expect_equal(model_result[["c"]], 2.898407831) - expect_equal(model_result[["pm"]], 151.851986) - expect_equal(model_result[["s"]], 0.345017009) - expect_equal(model_result[["ik"]], 440.1289906) - expect_equal(model_result[["im"]], 1399.769662) - expect_equal(model_result[["w"]], 1.18036237) } }) test_that("test-eilers_peeters_etr_I control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -47,17 +35,12 @@ test_that("test-eilers_peeters_etr_I control plot 20240925.csv", { }) test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) - - expect_no_warning( + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) model_result <- eilers_peeters_modified(model_result) - ) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) @@ -75,32 +58,16 @@ test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv", expect_equal(model_result[["w"]], 1.18036237) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) - # expect_equal(model_result[["a"]], 0.000001479) - # expect_equal(model_result[["b"]], 0.002444096) - expect_equal(model_result[["c"]], 2.898407831) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.345017009) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.851986) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 440.1289906) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 1399.769662) - expect_equal(model_result[["w"]], 1.18036237) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) } }) test_that("test-eilers_peeters_etr_I modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) - model_result <- eilers_peeters_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) + model_result <- eilers_peeters_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -109,4 +76,4 @@ test_that("test-eilers_peeters_etr_I modified control plot 20240925.csv", { ) ggplot2::ggsave("results/test-eilers_peeters_etr_I modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) }) -}) \ No newline at end of file +}) diff --git a/src/tests/testthat/test-eilers_peeters_etr_II.R b/src/tests/testthat/test-eilers_peeters_etr_II.R index 898c724..04c5b29 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_II.R +++ b/src/tests/testthat/test-eilers_peeters_etr_II.R @@ -1,11 +1,9 @@ test_that("test-eilers_peeters_etr_II generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) @@ -17,31 +15,18 @@ test_that("test-eilers_peeters_etr_II generate regression 20240925.csv", { expect_equal(model_result[["ik"]], 271.983185) expect_equal(model_result[["im"]], 731.801311) expect_equal(model_result[["w"]], 0.69061233) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) - # expect_equal(model_result[["a"]], 0) - # expect_equal(model_result[["b"]], 0.005765059) - expect_equal(model_result[["c"]], 6.10889648) - expect_equal(model_result[["pm"]], 44.52247403) - expect_equal(model_result[["s"]], 0.163695686) - expect_equal(model_result[["ik"]], 271.983185) - expect_equal(model_result[["im"]], 731.801311) - expect_equal(model_result[["w"]], 0.69061233) } }) test_that("test-eilers_peeters_etr_II modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) - expect_no_warning( - model_result <- eilers_peeters_modified(model_result) - ) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + model_result <- eilers_peeters_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) @@ -59,32 +44,16 @@ test_that("test-eilers_peeters_etr_II modified 20240925.csv", { expect_equal(model_result[["w"]], 0.69061233) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) - # expect_equal(model_result[["a"]], 0) - # expect_equal(model_result[["b"]], 0.005765059) - expect_equal(model_result[["c"]], 6.10889648) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.163695686) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.52247403) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 271.983185) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 731.801311) - expect_equal(model_result[["w"]], 0.69061233) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) } }) test_that("test-eilers_peeters_etr_II modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- model_result <- eilers_peeters_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + model_result <- model_result <- eilers_peeters_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R b/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R index d1c7c2a..47d5136 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R +++ b/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R @@ -1,11 +1,9 @@ test_that("test-eilers_peeters_etr_II generate regression junior_pam_20250613.csv.csv", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) @@ -17,31 +15,16 @@ test_that("test-eilers_peeters_etr_II generate regression junior_pam_20250613.cs expect_equal(model_result[["ik"]], 169.978939) expect_equal(model_result[["im"]], 1320.307821) expect_equal(model_result[["w"]], 5.7674788) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) - # expect_equal(model_result[["a"]], 0.000001594) - expect_equal(model_result[["b"]], 0.01213671) - expect_equal(model_result[["c"]], 2.77837046) - expect_equal(model_result[["pm"]], 61.1793644) - expect_equal(model_result[["s"]], 0.35992320) - expect_equal(model_result[["ik"]], 169.978939) - expect_equal(model_result[["im"]], 1320.307821) - expect_equal(model_result[["w"]], 5.7674788) } }) test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - - expect_no_warning( + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) model_result <- eilers_peeters_modified(model_result) - ) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) @@ -59,32 +42,16 @@ test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv", { expect_equal(model_result[["w"]], 5.7674788) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) - # expect_equal(model_result[["a"]], 0.000001594) - expect_equal(model_result[["b"]], 0.01213671) - expect_equal(model_result[["c"]], 2.77837046) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.35992320) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 61.1793644) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 169.978939) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 1320.307821) - expect_equal(model_result[["w"]], 5.7674788) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) } }) test_that("test-eilers_peeters_etr_II modified control plot junior_pam_20250613.csv", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- model_result <- eilers_peeters_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + model_result <- model_result <- eilers_peeters_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-get_etr_data_for_par_values.R b/src/tests/testthat/test-get_etr_data_for_par_values.R index 34e45b8..1cb3250 100644 --- a/src/tests/testthat/test-get_etr_data_for_par_values.R +++ b/src/tests/testthat/test-get_etr_data_for_par_values.R @@ -1,6 +1,6 @@ test_that("test-get_etr_data_for_par_values.R", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) diff --git a/src/tests/testthat/test-platt_etr_I.R b/src/tests/testthat/test-platt_etr_I.R index 3e49d9b..d68829b 100644 --- a/src/tests/testthat/test-platt_etr_I.R +++ b/src/tests/testthat/test-platt_etr_I.R @@ -1,11 +1,9 @@ test_that("test-platt_etr_I generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_I(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) @@ -17,28 +15,16 @@ test_that("test-platt_etr_I generate regression 20240925.csv", { expect_equal(model_result[["is"]], 689.94810) expect_equal(model_result[["ib"]], 4302.0636) expect_equal(model_result[["im"]], 1365.39202) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) - expect_equal(model_result[["alpha"]], 0.350792446) - expect_equal(model_result[["beta"]], 0.056258718) - expect_equal(model_result[["ps"]], 242.02858) - expect_equal(model_result[["pm"]], 151.8557330) - expect_equal(model_result[["ik"]], 432.893395) - expect_equal(model_result[["is"]], 689.94810) - expect_equal(model_result[["ib"]], 4302.0636) - expect_equal(model_result[["im"]], 1365.39202) } }) test_that("test-platt_etr_I generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_I(data) - model_result <- platt_modified(model_result) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + model_result <- platt_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) @@ -56,32 +42,16 @@ test_that("test-platt_etr_I generate regression modified 20240925.csv", { expect_equal(model_result[["w"]], NA_real_) expect_equal(model_result[["ib"]], 4302.0636) expect_equal(model_result[["etrmax_with_without_ratio"]], 1.59380602) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) - expect_equal(model_result[["a"]], 242.02858) - expect_equal(model_result[["b"]], 0.350792446) - expect_equal(model_result[["c"]], 0.056258718) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.350792446) - expect_equal(model_result[["beta"]], 0.056258718) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.8557330) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 242.02858) - expect_equal(model_result[["ik_with_photoinhibition"]], 432.893395) - expect_equal(model_result[["ik_without_photoinhibition"]], 689.94810) - expect_equal(model_result[["im_with_photoinhibition"]], 1365.39202) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], 4302.0636) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.59380602) } }) test_that("test-platt_etr_I modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_I(data) - model_result <- platt_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + model_result <- platt_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-platt_etr_II.R b/src/tests/testthat/test-platt_etr_II.R index 002f937..8ad03fb 100644 --- a/src/tests/testthat/test-platt_etr_II.R +++ b/src/tests/testthat/test-platt_etr_II.R @@ -1,11 +1,9 @@ test_that("test-platt_etr_II generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) @@ -17,25 +15,15 @@ test_that("test-platt_etr_II generate regression 20240925.csv", { expect_equal(model_result[["is"]], 429.51461) expect_equal(model_result[["ib"]], 2149.3914) expect_equal(model_result[["im"]], 769.889813) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) - expect_equal(model_result[["alpha"]], 0.178182856) - expect_equal(model_result[["beta"]], 0.035606423) - expect_equal(model_result[["ps"]], 76.532139) - expect_equal(model_result[["pm"]], 44.5824615) - expect_equal(model_result[["ik"]], 250.206234) - expect_equal(model_result[["is"]], 429.51461) - expect_equal(model_result[["ib"]], 2149.3914) - expect_equal(model_result[["im"]], 769.889813) } }) test_that("test-platt_etr_II control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -47,14 +35,12 @@ test_that("test-platt_etr_II control plot 20240925.csv", { }) test_that("test-platt_etr_II generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) - model_result <- platt_modified(model_result) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + model_result <- platt_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) @@ -72,32 +58,16 @@ test_that("test-platt_etr_II generate regression modified 20240925.csv", { expect_equal(model_result[["w"]], NA_real_) expect_equal(model_result[["ib"]], 2149.3914) expect_equal(model_result[["etrmax_with_without_ratio"]], 1.7166423) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) - expect_equal(model_result[["a"]], 76.532139) - expect_equal(model_result[["b"]], 0.178182856) - expect_equal(model_result[["c"]], 0.035606423) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.178182856) - expect_equal(model_result[["beta"]], 0.035606423) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.5824615) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 76.532139) - expect_equal(model_result[["ik_with_photoinhibition"]], 250.206234) - expect_equal(model_result[["ik_without_photoinhibition"]], 429.51461) - expect_equal(model_result[["im_with_photoinhibition"]], 769.889813) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], 2149.3914) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.7166423) } }) test_that("test-platt_etr_II modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) - model_result <- platt_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + model_result <- platt_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-read_dual_pam_data.R b/src/tests/testthat/test-read_dual_pam_data.R index d7b190e..ead6fd7 100644 --- a/src/tests/testthat/test-read_dual_pam_data.R +++ b/src/tests/testthat/test-read_dual_pam_data.R @@ -1,6 +1,8 @@ test_that("read_dual_pam_data 20240925.csv - default", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + }) par <- data$par expect_equal(par[1], 0) @@ -99,8 +101,10 @@ test_that("read_dual_pam_data 20240925.csv - default", { }) test_that("read_dual_pam_data 20240925.csv - etr_factor 0.5", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file, etr_factor = 0.5) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file, etr_factor = 0.5) + }) par <- data$par expect_equal(par[1], 0) @@ -200,13 +204,14 @@ test_that("read_dual_pam_data 20240925.csv - etr_factor 0.5", { test_that("read_dual_pam_data 20240925.csv - fraction_photosystem > 1", { test_data_file <- file.path(getwd(), "data", "20240925.csv") - expect_error(read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_dual_pam_data 20240925.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) + }) par <- data$par expect_equal(par[1], 0) @@ -312,4 +317,4 @@ test_that("20260130_01_efeutute_dual_pam_only_ps_1.csv - expect fm missing", { test_that("20260130_efeutute_dual_pam_only_ps_2.csv - expect pm missing", { test_data_file <- file.path(getwd(), "data", "20260130_efeutute_dual_pam_only_ps_2.csv") expect_error(read_dual_pam_data(test_data_file)) -}) \ No newline at end of file +}) diff --git a/src/tests/testthat/test-read_junior_pam_data.R b/src/tests/testthat/test-read_junior_pam_data.R index 38bfbd0..7e13e52 100644 --- a/src/tests/testthat/test-read_junior_pam_data.R +++ b/src/tests/testthat/test-read_junior_pam_data.R @@ -1,6 +1,8 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - default", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + }) par <- data$par expect_equal(par[1], 0) @@ -79,8 +81,10 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - default", { }) test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file, etr_factor = 0.5) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file, etr_factor = 0.5) + }) par <- data$par expect_equal(par[1], 0) @@ -160,13 +164,14 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem > 1", { test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - expect_error(read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) + }) par <- data$par expect_equal(par[1], 0) diff --git a/src/tests/testthat/test-read_universal_data.R b/src/tests/testthat/test-read_universal_data.R index d44c2d7..277a377 100644 --- a/src/tests/testthat/test-read_universal_data.R +++ b/src/tests/testthat/test-read_universal_data.R @@ -1,6 +1,8 @@ test_that("read_universal_data universal_data.csv - default", { - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "universal_data.csv") + data <- read_universal_data(test_data_file) + }) par <- data$par expect_equal(par[1], 0) @@ -99,8 +101,10 @@ test_that("read_universal_data universal_data.csv - default", { }) test_that("read_universal_data universal_data.csv - etr_factor 0.5", { - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file, etr_factor = 0.5) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "universal_data.csv") + data <- read_universal_data(test_data_file, etr_factor = 0.5) + }) par <- data$par expect_equal(par[1], 0) @@ -200,13 +204,14 @@ test_that("read_universal_data universal_data.csv - etr_factor 0.5", { test_that("read_universal_data universal_data.csv - fraction_photosystem > 1", { test_data_file <- file.path(getwd(), "data", "universal_data.csv") - expect_error(read_universal_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_universal_data universal_data.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "universal_data.csv") + data <- read_universal_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) + }) par <- data$par expect_equal(par[1], 0) diff --git a/src/tests/testthat/test-relative_root_mean_squared_error.R b/src/tests/testthat/test-relative_root_mean_squared_error.R index 763fb52..924cea7 100644 --- a/src/tests/testthat/test-relative_root_mean_squared_error.R +++ b/src/tests/testthat/test-relative_root_mean_squared_error.R @@ -1,6 +1,6 @@ test_that("test-relative_root_mean_squared_error.R", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) @@ -9,13 +9,7 @@ test_that("test-relative_root_mean_squared_error.R", { relative_root_mean_squared_error <- relative_root_mean_squared_error(result) }) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } - if (is_debian_or_ubuntu()) { expect_equal(relative_root_mean_squared_error, 0.0331529227874065) - } else if (is_windows()) { - expect_equal(relative_root_mean_squared_error, 0.0331529227874065) } }) diff --git a/src/tests/testthat/test-root_mean_squared_error.R b/src/tests/testthat/test-root_mean_squared_error.R index e219db6..f18ff4c 100644 --- a/src/tests/testthat/test-root_mean_squared_error.R +++ b/src/tests/testthat/test-root_mean_squared_error.R @@ -1,6 +1,6 @@ test_that("test-root_mean_squared_error.R", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) @@ -9,14 +9,7 @@ test_that("test-root_mean_squared_error.R", { root_mean_squared_error <- root_mean_squared_error(result) }) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } - if (is_debian_or_ubuntu()) { expect_equal(root_mean_squared_error, 0.88523222) - - } else if (is_windows()) { - expect_equal(root_mean_squared_error, 0.88523222) } }) diff --git a/src/tests/testthat/test-universal_data_etr_I.R b/src/tests/testthat/test-universal_data_etr_I.R index 2053245..4f24680 100644 --- a/src/tests/testthat/test-universal_data_etr_I.R +++ b/src/tests/testthat/test-universal_data_etr_I.R @@ -1,7 +1,6 @@ test_that("test-universal_data_etr_I", { - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - expect_no_error({ + test_data_file <- file.path(getwd(), "data", "universal_data.csv") data <- read_universal_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) @@ -9,10 +8,6 @@ test_that("test-universal_data_etr_I", { walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } - if (is_debian_or_ubuntu()) { expect_equal(eilers_peeters[["residual_sum_of_squares"]], 53.4454062) # expect_equal(eilers_peeters[["a"]], 0.000001479) @@ -29,22 +24,6 @@ test_that("test-universal_data_etr_I", { expect_equal(eilers_peeters[["w"]], 1.18036237) expect_equal(eilers_peeters[["ib"]], NA_real_) expect_equal(eilers_peeters[["etrmax_with_without_ratio"]], NA_real_) - } else if (is_windows()) { - expect_equal(eilers_peeters[["residual_sum_of_squares"]], 53.4454062) - # expect_equal(eilers_peeters[["a"]], 0.000001479) - # expect_equal(eilers_peeters[["b"]], 0.002444096) - expect_equal(eilers_peeters[["c"]], 2.898407831) - expect_equal(eilers_peeters[["d"]], NA_real_) - expect_equal(eilers_peeters[["alpha"]], 0.345017009) - expect_equal(eilers_peeters[["beta"]], NA_real_) - expect_equal(eilers_peeters[["etrmax_with_photoinhibition"]], 151.851986) - expect_equal(eilers_peeters[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(eilers_peeters[["ik_with_photoinhibition"]], 440.1289906) - expect_equal(eilers_peeters[["ik_without_photoinhibition"]], NA_real_) - expect_equal(eilers_peeters[["im_with_photoinhibition"]], 1399.769662) - expect_equal(eilers_peeters[["w"]], 1.18036237) - expect_equal(eilers_peeters[["ib"]], NA_real_) - expect_equal(eilers_peeters[["etrmax_with_without_ratio"]], NA_real_) } if (is_debian_or_ubuntu()) { @@ -63,22 +42,6 @@ test_that("test-universal_data_etr_I", { expect_equal(platt[["w"]], NA_real_) expect_equal(platt[["ib"]], 4302.0636) expect_equal(platt[["etrmax_with_without_ratio"]], 1.59380602) - } else if (is_windows()) { - expect_equal(platt[["residual_sum_of_squares"]], 55.4812913) - expect_equal(platt[["a"]], 242.02858) - expect_equal(platt[["b"]], 0.350792446) - expect_equal(platt[["c"]], 0.056258718) - expect_equal(platt[["d"]], NA_real_) - expect_equal(platt[["alpha"]], 0.350792446) - expect_equal(platt[["beta"]], 0.056258718) - expect_equal(platt[["etrmax_with_photoinhibition"]], 151.8557330) - expect_equal(platt[["etrmax_without_photoinhibition"]], 242.02858) - expect_equal(platt[["ik_with_photoinhibition"]], 432.893395) - expect_equal(platt[["ik_without_photoinhibition"]], 689.94810) - expect_equal(platt[["im_with_photoinhibition"]], 1365.39202) - expect_equal(platt[["w"]], NA_real_) - expect_equal(platt[["ib"]], 4302.0636) - expect_equal(platt[["etrmax_with_without_ratio"]], 1.59380602) } if (is_debian_or_ubuntu()) { @@ -97,22 +60,6 @@ test_that("test-universal_data_etr_I", { expect_equal(walsby[["w"]], NA_real_) expect_equal(walsby[["ib"]], NA_real_) expect_equal(walsby[["etrmax_with_without_ratio"]], 1.456840002) - } else if (is_windows()) { - expect_equal(walsby[["residual_sum_of_squares"]], 55.5823146) - expect_equal(walsby[["a"]], 221.237850) - expect_equal(walsby[["b"]], 0.387249941) - expect_equal(walsby[["c"]], -0.035964269) - expect_equal(walsby[["d"]], NA_real_) - expect_equal(walsby[["alpha"]], 0.387249941) - expect_equal(walsby[["beta"]], -0.035964269) - expect_equal(walsby[["etrmax_with_photoinhibition"]], 151.8614464) - expect_equal(walsby[["etrmax_without_photoinhibition"]], 221.237850) - expect_equal(walsby[["ik_with_photoinhibition"]], 392.153567) - expect_equal(walsby[["ik_without_photoinhibition"]], 571.305058) - expect_equal(walsby[["im_with_photoinhibition"]], 1358.0) - expect_equal(walsby[["w"]], NA_real_) - expect_equal(walsby[["ib"]], NA_real_) - expect_equal(walsby[["etrmax_with_without_ratio"]], 1.45684014) } if (is_debian_or_ubuntu()) { @@ -131,25 +78,8 @@ test_that("test-universal_data_etr_I", { expect_equal(vollenweider[["w"]], NA_real_) expect_equal(vollenweider[["ib"]], NA_real_) expect_equal(vollenweider[["etrmax_with_without_ratio"]], 1.254945) - } else if (is_windows()) { - expect_equal(vollenweider[["residual_sum_of_squares"]], 56.4705283) - expect_equal(vollenweider[["a"]], 181.19904) - # expect_equal(vollenweider[["b"]], 0.001864811) - # expect_equal(vollenweider[["c"]], 0.00001772) - expect_equal(vollenweider[["d"]], 0.046131240) - expect_equal(vollenweider[["alpha"]], 0.310402692) - expect_equal(vollenweider[["beta"]], NA_real_) - expect_equal(vollenweider[["etrmax_with_photoinhibition"]], 152.853737) - expect_equal(vollenweider[["etrmax_without_photoinhibition"]], 181.19904) - expect_equal(vollenweider[["ik_with_photoinhibition"]], 492.43689) - expect_equal(vollenweider[["ik_without_photoinhibition"]], 583.75472) - expect_equal(vollenweider[["im_with_photoinhibition"]], 1420.0) - expect_equal(vollenweider[["w"]], NA_real_) - expect_equal(vollenweider[["ib"]], NA_real_) - expect_equal(vollenweider[["etrmax_with_without_ratio"]], 1.18544068) } - plot <- combo_plot_control( "test-intermediate-table_etr_I.csv", data, diff --git a/src/tests/testthat/test-vollenweider_etr_I.R b/src/tests/testthat/test-vollenweider_etr_I.R index f3e199c..88df054 100644 --- a/src/tests/testthat/test-vollenweider_etr_I.R +++ b/src/tests/testthat/test-vollenweider_etr_I.R @@ -1,11 +1,9 @@ test_that("test-vollenweider_etr_I generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 55.4621712) @@ -17,25 +15,15 @@ test_that("test-vollenweider_etr_I generate regression 20240925.csv", { expect_equal(model_result[["popt"]], 152.615751) expect_equal(model_result[["iik"]], 488.76551) expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.254945) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 56.4705283) - expect_equal(model_result[["pmax"]], 181.19904) - # expect_equal(model_result[["a"]], 0.001864811) - # expect_equal(model_result[["alpha"]], 0.00001772) - expect_equal(model_result[["n"]], 0.046131240) - expect_equal(model_result[["ik"]], 583.75472) - expect_equal(model_result[["popt"]], 152.853737) - expect_equal(model_result[["iik"]], 492.43689) - expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.18544068) } }) test_that("test-vollenweider_etr_I control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -47,14 +35,12 @@ test_that("test-vollenweider_etr_I control plot 20240925.csv", { }) test_that("test-vollenweider_etr_I generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) - model_result <- vollenweider_modified(model_result) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + model_result <- vollenweider_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 55.4621712) @@ -72,32 +58,16 @@ test_that("test-vollenweider_etr_I generate regression modified 20240925.csv", { expect_equal(model_result[["w"]], NA_real_) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], 1.254945) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 56.4705283) - expect_equal(model_result[["a"]], 181.19904) - # expect_equal(model_result[["b"]], 0.001864811) - # expect_equal(model_result[["c"]], 0.00001772) - expect_equal(model_result[["d"]], 0.046131240) - expect_equal(model_result[["alpha"]], 0.310402692) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 152.853737) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 181.19904) - expect_equal(model_result[["ik_with_photoinhibition"]], 492.43689) - expect_equal(model_result[["ik_without_photoinhibition"]], 583.75472) - expect_equal(model_result[["im_with_photoinhibition"]], 1420.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.18544068) } }) test_that("test-vollenweider_etr_I modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) - model_result <- vollenweider_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + model_result <- vollenweider_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-vollenweider_etr_II.R b/src/tests/testthat/test-vollenweider_etr_II.R index f18aff3..f7f2039 100644 --- a/src/tests/testthat/test-vollenweider_etr_II.R +++ b/src/tests/testthat/test-vollenweider_etr_II.R @@ -1,11 +1,9 @@ test_that("test-vollenweider_etr_II generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 3.0153935) @@ -17,25 +15,15 @@ test_that("test-vollenweider_etr_II generate regression 20240925.csv", { expect_equal(model_result[["popt"]], 44.1785457) expect_equal(model_result[["iik"]], 289.657149) expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.194065095) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 3.01641889) - expect_equal(model_result[["pmax"]], 52.751066) - # expect_equal(model_result[["a"]], 0.002845961) - # expect_equal(model_result[["alpha"]], -0.000378034) - expect_equal(model_result[["n"]], 49.592988) - expect_equal(model_result[["ik"]], 345.86119) - expect_equal(model_result[["popt"]], 44.1788258) - expect_equal(model_result[["iik"]], 289.65748) - expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.194035044) } }) test_that("test-vollenweider_etr_II control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -47,14 +35,12 @@ test_that("test-vollenweider_etr_II control plot 20240925.csv", { }) test_that("test-vollenweider_etr_II generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) - model_result <- vollenweider_modified(model_result) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + model_result <- vollenweider_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 3.0153935) @@ -72,32 +58,16 @@ test_that("test-vollenweider_etr_II generate regression modified 20240925.csv", expect_equal(model_result[["w"]], NA_real_) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], 1.194065095) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 3.01641889) - expect_equal(model_result[["a"]], 52.751066) - # expect_equal(model_result[["b"]], 0.002845961) - # expect_equal(model_result[["c"]], -0.000378034) - expect_equal(model_result[["d"]], 49.592988) - expect_equal(model_result[["alpha"]], 0.15252092) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.1788258) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 52.751066) - expect_equal(model_result[["ik_with_photoinhibition"]], 289.65748) - expect_equal(model_result[["ik_without_photoinhibition"]], 345.86119) - expect_equal(model_result[["im_with_photoinhibition"]], 767.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.194035044) } }) test_that("test-vollenweider_etr_II modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) - model_result <- vollenweider_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + model_result <- vollenweider_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-walsby_etr_I.R b/src/tests/testthat/test-walsby_etr_I.R index 748962f..bb41449 100644 --- a/src/tests/testthat/test-walsby_etr_I.R +++ b/src/tests/testthat/test-walsby_etr_I.R @@ -1,31 +1,24 @@ test_that("test-walsby_etr_I generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) expect_equal(model_result[["etr_max"]], 221.237830) expect_equal(model_result[["alpha"]], 0.387249932) expect_equal(model_result[["beta"]], -0.035964258) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) - expect_equal(model_result[["etr_max"]], 221.237850) - expect_equal(model_result[["alpha"]], 0.387249941) - expect_equal(model_result[["beta"]], -0.035964269) } }) test_that("test-walsby_etr_I control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -38,14 +31,12 @@ test_that("test-walsby_etr_I control plot 20240925.csv", { }) test_that("test-walsby_etr_I generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) - model_result <- walsby_modified(model_result) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + model_result <- walsby_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) @@ -63,32 +54,16 @@ test_that("test-walsby_etr_I generate regression modified 20240925.csv", { expect_equal(model_result[["w"]], NA_real_) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], 1.456840002) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) - expect_equal(model_result[["a"]], 221.237850) - expect_equal(model_result[["b"]], 0.387249941) - expect_equal(model_result[["c"]], -0.035964269) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.387249941) - expect_equal(model_result[["beta"]], -0.035964269) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.8614464) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 221.237850) - expect_equal(model_result[["ik_with_photoinhibition"]], 392.153567) - expect_equal(model_result[["ik_without_photoinhibition"]], 571.305058) - expect_equal(model_result[["im_with_photoinhibition"]], 1358.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.45684014) } }) test_that("test-walsby_etr_I modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) - model_result <- walsby_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + model_result <- walsby_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-walsby_etr_II.R b/src/tests/testthat/test-walsby_etr_II.R index 9c8d0e9..b37de97 100644 --- a/src/tests/testthat/test-walsby_etr_II.R +++ b/src/tests/testthat/test-walsby_etr_II.R @@ -1,31 +1,25 @@ test_that("test-walsby_etr_II generate regression 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + }) - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) expect_equal(model_result[["etr_max"]], 64.620494) expect_equal(model_result[["alpha"]], 0.197966245) expect_equal(model_result[["beta"]], -0.018109015) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) - expect_equal(model_result[["etr_max"]], 64.620494) - expect_equal(model_result[["alpha"]], 0.197966245) - expect_equal(model_result[["beta"]], -0.018109014) } }) test_that("test-walsby_etr_II control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) - expect_no_warning({ plot <- plot_control( data, model_result, @@ -37,14 +31,12 @@ test_that("test-walsby_etr_II control plot 20240925.csv", { }) test_that("test-walsby_etr_II generate regression modified 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - model_result <- walsby_modified(model_result) - - if (is_supported_os() == FALSE) { - skip("Unsupported operating system for this test.") - } + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + model_result <- walsby_modified(model_result) + }) if (is_debian_or_ubuntu()) { expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) @@ -62,32 +54,16 @@ test_that("test-walsby_etr_II generate regression modified 20240925.csv", { expect_equal(model_result[["w"]], NA_real_) expect_equal(model_result[["ib"]], NA_real_) expect_equal(model_result[["etrmax_with_without_ratio"]], 1.44981217) - } else if (is_windows()) { - expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) - expect_equal(model_result[["a"]], 64.620494) - expect_equal(model_result[["b"]], 0.197966245) - expect_equal(model_result[["c"]], -0.018109014) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.197966245) - expect_equal(model_result[["beta"]], -0.018109014) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.5716318) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 64.620494) - expect_equal(model_result[["ik_with_photoinhibition"]], 225.147635) - expect_equal(model_result[["ik_without_photoinhibition"]], 326.4217749) - expect_equal(model_result[["im_with_photoinhibition"]], 781.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.449812147) } }) test_that("test-walsby_etr_II modified control plot 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - model_result <- walsby_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + model_result <- walsby_modified(model_result) - expect_no_warning({ plot <- plot_control( data, model_result, diff --git a/src/tests/testthat/test-write_model_result_csv.R b/src/tests/testthat/test-write_model_result_csv.R index b23195a..24c1527 100644 --- a/src/tests/testthat/test-write_model_result_csv.R +++ b/src/tests/testthat/test-write_model_result_csv.R @@ -1,13 +1,13 @@ test_that("test-write_model_result_csv - walsby_modified - 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - model_result <- walsby_modified(model_result) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + model_result <- walsby_modified(model_result) - result_dir <- file.path(getwd(), "results") - dir.create(result_dir, showWarnings = FALSE) + result_dir <- file.path(getwd(), "results") + dir.create(result_dir, showWarnings = FALSE) - expect_no_warning({ model_result_csv_path <- file.path(result_dir, "20240925_model_result.csv") raw_data_csv_path <- file.path(result_dir, "20240925_raw_data.csv") regression_data_csv_path <- file.path(result_dir, "20240925_regression_data.csv") @@ -54,14 +54,14 @@ test_that("test-write_model_result_csv - walsby_modified - 20240925.csv", { }) test_that("test-write_model_result_csv - walsby - 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) + expect_no_error({ + test_data_file <- file.path(getwd(), "data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) - result_dir <- file.path(getwd(), "results") - dir.create(result_dir, showWarnings = FALSE) + result_dir <- file.path(getwd(), "results") + dir.create(result_dir, showWarnings = FALSE) - expect_no_warning({ model_result_csv_path <- file.path(result_dir, "20240925_model_result.csv") raw_data_csv_path <- file.path(result_dir, "20240925_raw_data.csv") regression_data_csv_path <- file.path(result_dir, "20240925_regression_data.csv") From a78526f53b09c4d7c6e247b59f451050eccdd70f Mon Sep 17 00:00:00 2001 From: Phi-S <926151+Phi-S@users.noreply.github.com> Date: Sun, 15 Feb 2026 09:10:14 +0100 Subject: [PATCH 2/2] tests overhaul --- README.md | 4 +- .../testthat/test-combo_plot_control_etr_I.R | 2 +- .../testthat/test-combo_plot_control_etr_II.R | 2 +- .../test-compare_regression_models_etr_I.R | 16 +- .../test-compare_regression_models_etr_II.R | 4 +- .../test-compare_regression_models_total.R | 4 +- .../testthat/test-eilers_peeters_etr_I.R | 149 +++++++----- .../testthat/test-eilers_peeters_etr_II.R | 121 +++++----- .../test-eilers_peeters_etr_II_junior_pam.R | 63 ----- .../test-eilers_peeters_junior_pam_etr_II.R | 79 ++++++ .../test-get_etr_data_for_par_values.R | 224 +++++++++--------- src/tests/testthat/test-platt_etr_I.R | 127 +++++----- src/tests/testthat/test-platt_etr_II.R | 150 +++++++----- src/tests/testthat/test-read_dual_pam_data.R | 24 +- .../testthat/test-read_junior_pam_data.R | 20 +- src/tests/testthat/test-read_universal_data.R | 20 +- .../test-relative_root_mean_squared_error.R | 37 +-- .../testthat/test-root_mean_squared_error.R | 36 +-- .../testthat/test-universal_data_etr_I.R | 191 ++++++++------- src/tests/testthat/test-vollenweider_etr_I.R | 149 +++++++----- src/tests/testthat/test-vollenweider_etr_II.R | 150 +++++++----- src/tests/testthat/test-walsby_etr_I.R | 139 ++++++----- src/tests/testthat/test-walsby_etr_II.R | 139 ++++++----- .../testthat/test-write_model_result_csv.R | 178 +++++++------- 24 files changed, 1103 insertions(+), 925 deletions(-) delete mode 100644 src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R create mode 100644 src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R diff --git a/README.md b/README.md index 0b116df..99a5ba2 100644 --- a/README.md +++ b/README.md @@ -712,7 +712,7 @@ This function allows a straightforward comparison of the models: Eilers-Peeters ```r #raw data file directory -data_dir_compare <- file.path(getwd(), "data") +data_dir_compare <- testthat::test_path("data") #compare regression models compare_regression_models_ETR_II <- compare_regression_models_ETR_II(data_dir_compare, read_dual_pam_data) @@ -779,7 +779,7 @@ A plot displaying the original ETR and Yield values and the regression data from #### Examples ```r -test_data_file <- file.path(getwd(), "data", "20240925.csv") +test_data_file <- testthat::test_path("data", "20240925.csv") data <- read_dual_pam_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_II(data)) diff --git a/src/tests/testthat/test-combo_plot_control_etr_I.R b/src/tests/testthat/test-combo_plot_control_etr_I.R index 22da1c9..cf29b08 100644 --- a/src/tests/testthat/test-combo_plot_control_etr_I.R +++ b/src/tests/testthat/test-combo_plot_control_etr_I.R @@ -1,5 +1,5 @@ test_that("test-combo_plot_control 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") + test_data_file <- testthat::test_path("data", "20240925.csv") data <- read_dual_pam_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) diff --git a/src/tests/testthat/test-combo_plot_control_etr_II.R b/src/tests/testthat/test-combo_plot_control_etr_II.R index 8db85bc..798f8cd 100644 --- a/src/tests/testthat/test-combo_plot_control_etr_II.R +++ b/src/tests/testthat/test-combo_plot_control_etr_II.R @@ -1,5 +1,5 @@ test_that("test-combo_plot_control 20240925.csv", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") + test_data_file <- testthat::test_path("data", "20240925.csv") data <- read_dual_pam_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_II(data)) diff --git a/src/tests/testthat/test-compare_regression_models_etr_I.R b/src/tests/testthat/test-compare_regression_models_etr_I.R index 8150dfd..5e54236 100644 --- a/src/tests/testthat/test-compare_regression_models_etr_I.R +++ b/src/tests/testthat/test-compare_regression_models_etr_I.R @@ -1,16 +1,16 @@ test_that("compare_regression_models etr I - linux", { skip_if_not(is_debian_or_ubuntu()) - test_data_dir <- file.path(getwd(), "data", "bulk") - model_points_etr_1 <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) + test_data_dir <- testthat::test_path("data", "bulk") + result <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) - expect_equal(model_points_etr_I[["eilers_peeters"]], 13) - expect_equal(model_points_etr_I[["platt"]], 19) - expect_equal(model_points_etr_I[["vollenweider"]], 33) - expect_equal(model_points_etr_I[["walsby"]], 25) + expect_equal(result[["eilers_peeters"]], 13) + expect_equal(result[["platt"]], 19) + expect_equal(result[["vollenweider"]], 33) + expect_equal(result[["walsby"]], 25) }) test_that("compare_regression_models etr I", { - test_data_dir <- file.path(getwd(), "data", "bulk") - model_points_etr_1 <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) + test_data_dir <- testthat::test_path("data", "bulk") + result <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) expect_named(result, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) }) diff --git a/src/tests/testthat/test-compare_regression_models_etr_II.R b/src/tests/testthat/test-compare_regression_models_etr_II.R index fdb980f..919d238 100644 --- a/src/tests/testthat/test-compare_regression_models_etr_II.R +++ b/src/tests/testthat/test-compare_regression_models_etr_II.R @@ -1,7 +1,7 @@ test_that("compare_regression_models etr II - linux", { skip_if_not(is_debian_or_ubuntu()) - test_data_dir <- file.path(getwd(), "data", "bulk") + test_data_dir <- testthat::test_path("data", "bulk") result <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) expect_equal(result[["eilers_peeters"]], 37) @@ -11,7 +11,7 @@ test_that("compare_regression_models etr II - linux", { }) test_that("compare_regression_models etr II", { - test_data_dir <- file.path(getwd(), "data", "bulk") + test_data_dir <- testthat::test_path("data", "bulk") result <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) expect_named(result, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) }) diff --git a/src/tests/testthat/test-compare_regression_models_total.R b/src/tests/testthat/test-compare_regression_models_total.R index ce8285c..3c6f43a 100644 --- a/src/tests/testthat/test-compare_regression_models_total.R +++ b/src/tests/testthat/test-compare_regression_models_total.R @@ -1,6 +1,6 @@ test_that("compare_regression_models etr I + II - linux", { skip_if_not(is_debian_or_ubuntu()) - test_data_dir <- file.path(getwd(), "data", "bulk") + test_data_dir <- testthat::test_path("data", "bulk") model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) @@ -16,7 +16,7 @@ test_that("compare_regression_models etr I + II - linux", { }) test_that("compare_regression_models etr I + II", { - test_data_dir <- file.path(getwd(), "data", "bulk") + test_data_dir <- testthat::test_path("data", "bulk") model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) expect_named(model_points_etr_I, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) diff --git a/src/tests/testthat/test-eilers_peeters_etr_I.R b/src/tests/testthat/test-eilers_peeters_etr_I.R index c693ec3..b3cf615 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_I.R +++ b/src/tests/testthat/test-eilers_peeters_etr_I.R @@ -1,79 +1,98 @@ -test_that("test-eilers_peeters_etr_I generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) - }) +test_that("test-eilers_peeters_etr_I generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) - # expect_equal(model_result[["a"]], 0.000001479) - # expect_equal(model_result[["b"]], 0.002444096) - expect_equal(model_result[["c"]], 2.898407831) - expect_equal(model_result[["pm"]], 151.851986) - expect_equal(model_result[["s"]], 0.345017009) - expect_equal(model_result[["ik"]], 440.1289906) - expect_equal(model_result[["im"]], 1399.769662) - expect_equal(model_result[["w"]], 1.18036237) - } + expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) + # expect_equal(model_result[["a"]], 0.000001479) + # expect_equal(model_result[["b"]], 0.002444096) + expect_equal(model_result[["c"]], 2.898407831) + expect_equal(model_result[["pm"]], 151.851986) + expect_equal(model_result[["s"]], 0.345017009) + expect_equal(model_result[["ik"]], 440.1289906) + expect_equal(model_result[["im"]], 1399.769662) + expect_equal(model_result[["w"]], 1.18036237) +}) + +test_that("test-eilers_peeters_etr_I generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) }) test_that("test-eilers_peeters_etr_I control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) + + plot <- plot_control( + data, + model_result, + "eilers_peeters ETR I 20240925.csv", + color_eilers_peeters + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "eilers_peeters ETR I 20240925.csv", - color_eilers_peeters - ) - ggplot2::ggsave("results/test-eilers_peeters_etr_I control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-eilers_peeters_etr_I control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) + +test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) + model_result <- eilers_peeters_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) + # expect_equal(model_result[["a"]], 0.000001479) + # expect_equal(model_result[["b"]], 0.002444096) + expect_equal(model_result[["c"]], 2.898407831) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.345017009) + expect_equal(model_result[["beta"]], NA_real_) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.851986) + expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) + expect_equal(model_result[["ik_with_photoinhibition"]], 440.1289906) + expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) + expect_equal(model_result[["im_with_photoinhibition"]], 1399.769662) + expect_equal(model_result[["w"]], 1.18036237) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) }) test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) - model_result <- eilers_peeters_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + + model_result <- eilers_peeters_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 53.4454062) - # expect_equal(model_result[["a"]], 0.000001479) - # expect_equal(model_result[["b"]], 0.002444096) - expect_equal(model_result[["c"]], 2.898407831) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.345017009) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.851986) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 440.1289906) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 1399.769662) - expect_equal(model_result[["w"]], 1.18036237) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) - } + model_result <- eilers_peeters_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-eilers_peeters_etr_I modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_I(data) - model_result <- eilers_peeters_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_I(data) + model_result <- eilers_peeters_modified(model_result) + + plot <- plot_control( + data, + model_result, + "eilers_peeters ETR I modified 20240925.csv", + color_eilers_peeters + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "eilers_peeters ETR I modified 20240925.csv", - color_eilers_peeters - ) - ggplot2::ggsave("results/test-eilers_peeters_etr_I modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-eilers_peeters_etr_I modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-eilers_peeters_etr_II.R b/src/tests/testthat/test-eilers_peeters_etr_II.R index 04c5b29..3d722db 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_II.R +++ b/src/tests/testthat/test-eilers_peeters_etr_II.R @@ -1,65 +1,78 @@ -test_that("test-eilers_peeters_etr_II generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - }) +test_that("test-eilers_peeters_etr_II generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) - # expect_equal(model_result[["a"]], 0) - # expect_equal(model_result[["b"]], 0.005765059) - expect_equal(model_result[["c"]], 6.10889648) - expect_equal(model_result[["pm"]], 44.52247403) - expect_equal(model_result[["s"]], 0.163695686) - expect_equal(model_result[["ik"]], 271.983185) - expect_equal(model_result[["im"]], 731.801311) - expect_equal(model_result[["w"]], 0.69061233) - } + expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) + # expect_equal(model_result[["a"]], 0) + # expect_equal(model_result[["b"]], 0.005765059) + expect_equal(model_result[["c"]], 6.10889648) + expect_equal(model_result[["pm"]], 44.52247403) + expect_equal(model_result[["s"]], 0.163695686) + expect_equal(model_result[["ik"]], 271.983185) + expect_equal(model_result[["im"]], 731.801311) + expect_equal(model_result[["w"]], 0.69061233) }) -test_that("test-eilers_peeters_etr_II modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) +test_that("test-eilers_peeters_etr_II generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) +}) +test_that("test-eilers_peeters_etr_II modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) - model_result <- eilers_peeters_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + model_result <- eilers_peeters_modified(model_result) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) - # expect_equal(model_result[["a"]], 0) - # expect_equal(model_result[["b"]], 0.005765059) - expect_equal(model_result[["c"]], 6.108896488) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.163695686) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.52247403) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 271.983185) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 731.801311) - expect_equal(model_result[["w"]], 0.69061233) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) - } + expect_equal(model_result[["residual_sum_of_squares"]], 5.7818334) + # expect_equal(model_result[["a"]], 0) + # expect_equal(model_result[["b"]], 0.005765059) + expect_equal(model_result[["c"]], 6.108896488) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.163695686) + expect_equal(model_result[["beta"]], NA_real_) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.52247403) + expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) + expect_equal(model_result[["ik_with_photoinhibition"]], 271.983185) + expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) + expect_equal(model_result[["im_with_photoinhibition"]], 731.801311) + expect_equal(model_result[["w"]], 0.69061233) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) +}) + +test_that("test-eilers_peeters_etr_II modified 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) + + model_result <- eilers_peeters_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-eilers_peeters_etr_II modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- model_result <- eilers_peeters_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + model_result <- model_result <- eilers_peeters_modified(model_result) + + plot <- plot_control( + data, + model_result, + "eilers_peeters ETR II modified 20240925.csv", + color_eilers_peeters + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "eilers_peeters ETR II modified 20240925.csv", - color_eilers_peeters - ) - ggplot2::ggsave("results/test-eilers_peeters_etr_II modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-eilers_peeters_etr_II modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R b/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R deleted file mode 100644 index 47d5136..0000000 --- a/src/tests/testthat/test-eilers_peeters_etr_II_junior_pam.R +++ /dev/null @@ -1,63 +0,0 @@ -test_that("test-eilers_peeters_etr_II generate regression junior_pam_20250613.csv.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - }) - - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) - # expect_equal(model_result[["a"]], 0.000001594) - expect_equal(model_result[["b"]], 0.01213671) - expect_equal(model_result[["c"]], 2.77837046) - expect_equal(model_result[["pm"]], 61.1793644) - expect_equal(model_result[["s"]], 0.35992320) - expect_equal(model_result[["ik"]], 169.978939) - expect_equal(model_result[["im"]], 1320.307821) - expect_equal(model_result[["w"]], 5.7674788) - } -}) - -test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- eilers_peeters_modified(model_result) - }) - - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) - # expect_equal(model_result[["a"]], 0.000001594) - expect_equal(model_result[["b"]], 0.01213671) - expect_equal(model_result[["c"]], 2.77837046) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.35992320) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 61.1793644) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 169.978939) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 1320.307821) - expect_equal(model_result[["w"]], 5.7674788) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) - } -}) - -test_that("test-eilers_peeters_etr_II modified control plot junior_pam_20250613.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- model_result <- eilers_peeters_modified(model_result) - - plot <- plot_control( - data, - model_result, - "eilers_peeters ETR II modified junior_pam_20250613.csv", - color_eilers_peeters - ) - ggplot2::ggsave("results/test-eilers_peeters_etr_II modified control plot junior_pam_20250613.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) -}) diff --git a/src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R b/src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R new file mode 100644 index 0000000..eb9d39c --- /dev/null +++ b/src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R @@ -0,0 +1,79 @@ +test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + + expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) + # expect_equal(model_result[["a"]], 0.000001594) + expect_equal(model_result[["b"]], 0.01213671) + expect_equal(model_result[["c"]], 2.77837046) + expect_equal(model_result[["pm"]], 61.1793644) + expect_equal(model_result[["s"]], 0.35992320) + expect_equal(model_result[["ik"]], 169.978939) + expect_equal(model_result[["im"]], 1320.307821) + expect_equal(model_result[["w"]], 5.7674788) +}) + +test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv", { + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) +}) + +test_that("test-eilers_peeters_etr_II modified junior_pam_20250613.csv.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + model_result <- eilers_peeters_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) + # expect_equal(model_result[["a"]], 0.000001594) + expect_equal(model_result[["b"]], 0.01213671) + expect_equal(model_result[["c"]], 2.77837046) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.35992320) + expect_equal(model_result[["beta"]], NA_real_) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 61.1793644) + expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) + expect_equal(model_result[["ik_with_photoinhibition"]], 169.978939) + expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) + expect_equal(model_result[["im_with_photoinhibition"]], 1320.307821) + expect_equal(model_result[["w"]], 5.7674788) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], NA_real_) +}) + +test_that("test-eilers_peeters_etr_II modified junior_pam_20250613.csv.csv", { + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + + model_result <- eilers_peeters_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) + + model_result <- eilers_peeters_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) +}) + +test_that("test-eilers_peeters_etr_II modified control plot junior_pam_20250613.csv", { + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) + model_result <- eilers_peeters_generate_regression_ETR_II(data) + model_result <- model_result <- eilers_peeters_modified(model_result) + + plot <- plot_control( + data, + model_result, + "eilers_peeters ETR II modified junior_pam_20250613.csv", + color_eilers_peeters + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) + + out <- file.path("results", "test-eilers_peeters_etr_II modified control plot junior_pam_20250613.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) diff --git a/src/tests/testthat/test-get_etr_data_for_par_values.R b/src/tests/testthat/test-get_etr_data_for_par_values.R index 1cb3250..7e8022a 100644 --- a/src/tests/testthat/test-get_etr_data_for_par_values.R +++ b/src/tests/testthat/test-get_etr_data_for_par_values.R @@ -1,118 +1,116 @@ test_that("test-get_etr_data_for_par_values.R", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - etr_regression_data <- get_etr_regression_data_from_model_result(model_result) - result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + etr_regression_data <- get_etr_regression_data_from_model_result(model_result) + result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) - par <- result[[PAR_name]] - expect_equal(par[1], data[[PAR_name]][1]) - expect_equal(par[2], data[[PAR_name]][2]) - expect_equal(par[3], data[[PAR_name]][3]) - expect_equal(par[4], data[[PAR_name]][4]) - expect_equal(par[5], data[[PAR_name]][5]) - expect_equal(par[6], data[[PAR_name]][6]) - expect_equal(par[7], data[[PAR_name]][7]) - expect_equal(par[8], data[[PAR_name]][8]) - expect_equal(par[9], data[[PAR_name]][9]) - expect_equal(par[10], data[[PAR_name]][10]) - expect_equal(par[11], data[[PAR_name]][11]) - expect_equal(par[12], data[[PAR_name]][12]) - expect_equal(par[13], data[[PAR_name]][13]) - expect_equal(par[14], data[[PAR_name]][14]) - expect_equal(par[15], data[[PAR_name]][15]) - expect_equal(par[16], data[[PAR_name]][16]) - expect_equal(par[17], data[[PAR_name]][17]) + par <- result[[PAR_name]] + expect_equal(par[1], data[[PAR_name]][1]) + expect_equal(par[2], data[[PAR_name]][2]) + expect_equal(par[3], data[[PAR_name]][3]) + expect_equal(par[4], data[[PAR_name]][4]) + expect_equal(par[5], data[[PAR_name]][5]) + expect_equal(par[6], data[[PAR_name]][6]) + expect_equal(par[7], data[[PAR_name]][7]) + expect_equal(par[8], data[[PAR_name]][8]) + expect_equal(par[9], data[[PAR_name]][9]) + expect_equal(par[10], data[[PAR_name]][10]) + expect_equal(par[11], data[[PAR_name]][11]) + expect_equal(par[12], data[[PAR_name]][12]) + expect_equal(par[13], data[[PAR_name]][13]) + expect_equal(par[14], data[[PAR_name]][14]) + expect_equal(par[15], data[[PAR_name]][15]) + expect_equal(par[16], data[[PAR_name]][16]) + expect_equal(par[17], data[[PAR_name]][17]) - measured_etr <- result$measured_etr - expect_equal(measured_etr[1], data[[etr_2_type]][1]) - expect_equal(measured_etr[2], data[[etr_2_type]][2]) - expect_equal(measured_etr[3], data[[etr_2_type]][3]) - expect_equal(measured_etr[3], data[[etr_2_type]][3]) - expect_equal(measured_etr[4], data[[etr_2_type]][4]) - expect_equal(measured_etr[5], data[[etr_2_type]][5]) - expect_equal(measured_etr[6], data[[etr_2_type]][6]) - expect_equal(measured_etr[7], data[[etr_2_type]][7]) - expect_equal(measured_etr[8], data[[etr_2_type]][8]) - expect_equal(measured_etr[9], data[[etr_2_type]][9]) - expect_equal(measured_etr[10], data[[etr_2_type]][10]) - expect_equal(measured_etr[11], data[[etr_2_type]][11]) - expect_equal(measured_etr[12], data[[etr_2_type]][12]) - expect_equal(measured_etr[13], data[[etr_2_type]][13]) - expect_equal(measured_etr[14], data[[etr_2_type]][14]) - expect_equal(measured_etr[15], data[[etr_2_type]][15]) - expect_equal(measured_etr[16], data[[etr_2_type]][16]) - expect_equal(measured_etr[17], data[[etr_2_type]][17]) + measured_etr <- result$measured_etr + expect_equal(measured_etr[1], data[[etr_2_type]][1]) + expect_equal(measured_etr[2], data[[etr_2_type]][2]) + expect_equal(measured_etr[3], data[[etr_2_type]][3]) + expect_equal(measured_etr[3], data[[etr_2_type]][3]) + expect_equal(measured_etr[4], data[[etr_2_type]][4]) + expect_equal(measured_etr[5], data[[etr_2_type]][5]) + expect_equal(measured_etr[6], data[[etr_2_type]][6]) + expect_equal(measured_etr[7], data[[etr_2_type]][7]) + expect_equal(measured_etr[8], data[[etr_2_type]][8]) + expect_equal(measured_etr[9], data[[etr_2_type]][9]) + expect_equal(measured_etr[10], data[[etr_2_type]][10]) + expect_equal(measured_etr[11], data[[etr_2_type]][11]) + expect_equal(measured_etr[12], data[[etr_2_type]][12]) + expect_equal(measured_etr[13], data[[etr_2_type]][13]) + expect_equal(measured_etr[14], data[[etr_2_type]][14]) + expect_equal(measured_etr[15], data[[etr_2_type]][15]) + expect_equal(measured_etr[16], data[[etr_2_type]][16]) + expect_equal(measured_etr[17], data[[etr_2_type]][17]) - predicted_etr <- result$predicted_etr - expect_equal( - predicted_etr[1], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][1], ][[prediction_name]] - ) - expect_equal( - predicted_etr[2], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][2], ][[prediction_name]] - ) - expect_equal( - predicted_etr[3], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][3], ][[prediction_name]] - ) - expect_equal( - predicted_etr[4], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][4], ][[prediction_name]] - ) - expect_equal( - predicted_etr[5], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][5], ][[prediction_name]] - ) - expect_equal( - predicted_etr[6], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][6], ][[prediction_name]] - ) - expect_equal( - predicted_etr[7], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][7], ][[prediction_name]] - ) - expect_equal( - predicted_etr[8], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][8], ][[prediction_name]] - ) - expect_equal( - predicted_etr[9], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][9], ][[prediction_name]] - ) - expect_equal( - predicted_etr[10], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][10], ][[prediction_name]] - ) - expect_equal( - predicted_etr[11], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][11], ][[prediction_name]] - ) - expect_equal( - predicted_etr[12], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][12], ][[prediction_name]] - ) - expect_equal( - predicted_etr[13], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][13], ][[prediction_name]] - ) - expect_equal( - predicted_etr[14], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][14], ][[prediction_name]] - ) - expect_equal( - predicted_etr[15], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][15], ][[prediction_name]] - ) - expect_equal( - predicted_etr[16], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][16], ][[prediction_name]] - ) - expect_equal( - predicted_etr[17], - etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][17], ][[prediction_name]] - ) - }) + predicted_etr <- result$predicted_etr + expect_equal( + predicted_etr[1], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][1], ][[prediction_name]] + ) + expect_equal( + predicted_etr[2], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][2], ][[prediction_name]] + ) + expect_equal( + predicted_etr[3], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][3], ][[prediction_name]] + ) + expect_equal( + predicted_etr[4], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][4], ][[prediction_name]] + ) + expect_equal( + predicted_etr[5], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][5], ][[prediction_name]] + ) + expect_equal( + predicted_etr[6], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][6], ][[prediction_name]] + ) + expect_equal( + predicted_etr[7], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][7], ][[prediction_name]] + ) + expect_equal( + predicted_etr[8], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][8], ][[prediction_name]] + ) + expect_equal( + predicted_etr[9], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][9], ][[prediction_name]] + ) + expect_equal( + predicted_etr[10], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][10], ][[prediction_name]] + ) + expect_equal( + predicted_etr[11], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][11], ][[prediction_name]] + ) + expect_equal( + predicted_etr[12], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][12], ][[prediction_name]] + ) + expect_equal( + predicted_etr[13], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][13], ][[prediction_name]] + ) + expect_equal( + predicted_etr[14], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][14], ][[prediction_name]] + ) + expect_equal( + predicted_etr[15], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][15], ][[prediction_name]] + ) + expect_equal( + predicted_etr[16], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][16], ][[prediction_name]] + ) + expect_equal( + predicted_etr[17], + etr_regression_data[etr_regression_data[[PAR_name]] == result[[PAR_name]][17], ][[prediction_name]] + ) }) diff --git a/src/tests/testthat/test-platt_etr_I.R b/src/tests/testthat/test-platt_etr_I.R index d68829b..75cf0da 100644 --- a/src/tests/testthat/test-platt_etr_I.R +++ b/src/tests/testthat/test-platt_etr_I.R @@ -1,63 +1,80 @@ +test_that("test-platt_etr_I generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + + expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) + expect_equal(model_result[["alpha"]], 0.350792446) + expect_equal(model_result[["beta"]], 0.056258718) + expect_equal(model_result[["ps"]], 242.02858) + expect_equal(model_result[["pm"]], 151.8557330) + expect_equal(model_result[["ik"]], 432.893395) + expect_equal(model_result[["is"]], 689.94810) + expect_equal(model_result[["ib"]], 4302.0636) + expect_equal(model_result[["im"]], 1365.39202) +}) + test_that("test-platt_etr_I generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_I(data) - }) - - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) - expect_equal(model_result[["alpha"]], 0.350792446) - expect_equal(model_result[["beta"]], 0.056258718) - expect_equal(model_result[["ps"]], 242.02858) - expect_equal(model_result[["pm"]], 151.8557330) - expect_equal(model_result[["ik"]], 432.893395) - expect_equal(model_result[["is"]], 689.94810) - expect_equal(model_result[["ib"]], 4302.0636) - expect_equal(model_result[["im"]], 1365.39202) - } + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) +}) + +test_that("test-platt_etr_I generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + model_result <- platt_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) + expect_equal(model_result[["a"]], 242.02858) + expect_equal(model_result[["b"]], 0.350792446) + expect_equal(model_result[["c"]], 0.056258718) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.350792446) + expect_equal(model_result[["beta"]], 0.056258718) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.8557330) + expect_equal(model_result[["etrmax_without_photoinhibition"]], 242.02858) + expect_equal(model_result[["ik_with_photoinhibition"]], 432.893395) + expect_equal(model_result[["ik_without_photoinhibition"]], 689.94810) + expect_equal(model_result[["im_with_photoinhibition"]], 1365.39202) + expect_equal(model_result[["w"]], NA_real_) + expect_equal(model_result[["ib"]], 4302.0636) + expect_equal(model_result[["etrmax_with_without_ratio"]], 1.59380602) }) test_that("test-platt_etr_I generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_I(data) - model_result <- platt_modified(model_result) - }) - - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.4812913) - expect_equal(model_result[["a"]], 242.02858) - expect_equal(model_result[["b"]], 0.350792446) - expect_equal(model_result[["c"]], 0.056258718) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.350792446) - expect_equal(model_result[["beta"]], 0.056258718) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.8557330) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 242.02858) - expect_equal(model_result[["ik_with_photoinhibition"]], 432.893395) - expect_equal(model_result[["ik_without_photoinhibition"]], 689.94810) - expect_equal(model_result[["im_with_photoinhibition"]], 1365.39202) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], 4302.0636) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.59380602) - } + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + + model_result <- platt_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) + + model_result <- platt_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-platt_etr_I modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_I(data) - model_result <- platt_modified(model_result) - - plot <- plot_control( - data, - model_result, - "platt ETR I modified 20240925.csv", - color_platt - ) - ggplot2::ggsave("results/test-platt_etr_I modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_I(data) + model_result <- platt_modified(model_result) + + plot <- plot_control( + data, + model_result, + "platt ETR I modified 20240925.csv", + color_platt + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) + + out <- file.path("results", "test-platt_etr_I modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-platt_etr_II.R b/src/tests/testthat/test-platt_etr_II.R index 8ad03fb..88401b6 100644 --- a/src/tests/testthat/test-platt_etr_II.R +++ b/src/tests/testthat/test-platt_etr_II.R @@ -1,79 +1,99 @@ -test_that("test-platt_etr_II generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) - }) +test_that("test-platt_etr_II generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + + expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) + expect_equal(model_result[["alpha"]], 0.178182856) + expect_equal(model_result[["beta"]], 0.035606423) + expect_equal(model_result[["ps"]], 76.532139) + expect_equal(model_result[["pm"]], 44.5824615) + expect_equal(model_result[["ik"]], 250.206234) + expect_equal(model_result[["is"]], 429.51461) + expect_equal(model_result[["ib"]], 2149.3914) + expect_equal(model_result[["im"]], 769.889813) +}) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) - expect_equal(model_result[["alpha"]], 0.178182856) - expect_equal(model_result[["beta"]], 0.035606423) - expect_equal(model_result[["ps"]], 76.532139) - expect_equal(model_result[["pm"]], 44.5824615) - expect_equal(model_result[["ik"]], 250.206234) - expect_equal(model_result[["is"]], 429.51461) - expect_equal(model_result[["ib"]], 2149.3914) - expect_equal(model_result[["im"]], 769.889813) - } +test_that("test-platt_etr_II generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) }) test_that("test-platt_etr_II control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + + plot <- plot_control( + data, + model_result, + "platt ETR II 20240925.csv", + color_platt + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "platt ETR II 20240925.csv", - color_platt - ) - ggplot2::ggsave("results/test-platt_etr_II control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-platt_etr_II control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) + +test_that("test-platt_etr_II generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + model_result <- platt_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) + expect_equal(model_result[["a"]], 76.532139) + expect_equal(model_result[["b"]], 0.178182856) + expect_equal(model_result[["c"]], 0.035606423) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.178182856) + expect_equal(model_result[["beta"]], 0.035606423) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.5824615) + expect_equal(model_result[["etrmax_without_photoinhibition"]], 76.532139) + expect_equal(model_result[["ik_with_photoinhibition"]], 250.206234) + expect_equal(model_result[["ik_without_photoinhibition"]], 429.51461) + expect_equal(model_result[["im_with_photoinhibition"]], 769.889813) + expect_equal(model_result[["w"]], NA_real_) + expect_equal(model_result[["ib"]], 2149.3914) + expect_equal(model_result[["etrmax_with_without_ratio"]], 1.7166423) }) test_that("test-platt_etr_II generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) - model_result <- platt_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 12.0348133) - expect_equal(model_result[["a"]], 76.532139) - expect_equal(model_result[["b"]], 0.178182856) - expect_equal(model_result[["c"]], 0.035606423) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.178182856) - expect_equal(model_result[["beta"]], 0.035606423) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.5824615) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 76.532139) - expect_equal(model_result[["ik_with_photoinhibition"]], 250.206234) - expect_equal(model_result[["ik_without_photoinhibition"]], 429.51461) - expect_equal(model_result[["im_with_photoinhibition"]], 769.889813) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], 2149.3914) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.7166423) - } + model_result <- platt_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-platt_etr_II modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- platt_generate_regression_ETR_II(data) - model_result <- platt_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- platt_generate_regression_ETR_II(data) + + model_result <- platt_modified(model_result) + + plot <- plot_control( + data, + model_result, + "platt ETR II modified 20240925.csv", + color_platt + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "platt ETR II modified 20240925.csv", - color_platt - ) - ggplot2::ggsave("results/test-platt_etr_II modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-platt_etr_II modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-read_dual_pam_data.R b/src/tests/testthat/test-read_dual_pam_data.R index ead6fd7..925428c 100644 --- a/src/tests/testthat/test-read_dual_pam_data.R +++ b/src/tests/testthat/test-read_dual_pam_data.R @@ -1,8 +1,6 @@ test_that("read_dual_pam_data 20240925.csv - default", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) par <- data$par expect_equal(par[1], 0) @@ -101,10 +99,8 @@ test_that("read_dual_pam_data 20240925.csv - default", { }) test_that("read_dual_pam_data 20240925.csv - etr_factor 0.5", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file, etr_factor = 0.5) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file, etr_factor = 0.5) par <- data$par expect_equal(par[1], 0) @@ -203,15 +199,13 @@ test_that("read_dual_pam_data 20240925.csv - etr_factor 0.5", { }) test_that("read_dual_pam_data 20240925.csv - fraction_photosystem > 1", { - test_data_file <- file.path(getwd(), "data", "20240925.csv") + test_data_file <- testthat::test_path("data", "20240925.csv") expect_error(read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_dual_pam_data 20240925.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par expect_equal(par[1], 0) @@ -310,11 +304,11 @@ test_that("read_dual_pam_data 20240925.csv - fraction_photosystem_I = 0.2, fract }) test_that("20260130_01_efeutute_dual_pam_only_ps_1.csv - expect fm missing", { - test_data_file <- file.path(getwd(), "data", "20260130_01_efeutute_dual_pam_only_ps_1.csv") + test_data_file <- testthat::test_path("data", "20260130_01_efeutute_dual_pam_only_ps_1.csv") expect_error(read_dual_pam_data(test_data_file)) }) test_that("20260130_efeutute_dual_pam_only_ps_2.csv - expect pm missing", { - test_data_file <- file.path(getwd(), "data", "20260130_efeutute_dual_pam_only_ps_2.csv") + test_data_file <- testthat::test_path("data", "20260130_efeutute_dual_pam_only_ps_2.csv") expect_error(read_dual_pam_data(test_data_file)) }) diff --git a/src/tests/testthat/test-read_junior_pam_data.R b/src/tests/testthat/test-read_junior_pam_data.R index 7e13e52..8290928 100644 --- a/src/tests/testthat/test-read_junior_pam_data.R +++ b/src/tests/testthat/test-read_junior_pam_data.R @@ -1,8 +1,6 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - default", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - }) + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file) par <- data$par expect_equal(par[1], 0) @@ -81,10 +79,8 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - default", { }) test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file, etr_factor = 0.5) - }) + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file, etr_factor = 0.5) par <- data$par expect_equal(par[1], 0) @@ -163,15 +159,13 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { }) test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem > 1", { - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") expect_error(read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) - }) + test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") + data <- read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par expect_equal(par[1], 0) diff --git a/src/tests/testthat/test-read_universal_data.R b/src/tests/testthat/test-read_universal_data.R index 277a377..e07470e 100644 --- a/src/tests/testthat/test-read_universal_data.R +++ b/src/tests/testthat/test-read_universal_data.R @@ -1,8 +1,6 @@ test_that("read_universal_data universal_data.csv - default", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file) - }) + test_data_file <- testthat::test_path("data", "universal_data.csv") + data <- read_universal_data(test_data_file) par <- data$par expect_equal(par[1], 0) @@ -101,10 +99,8 @@ test_that("read_universal_data universal_data.csv - default", { }) test_that("read_universal_data universal_data.csv - etr_factor 0.5", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file, etr_factor = 0.5) - }) + test_data_file <- testthat::test_path("data", "universal_data.csv") + data <- read_universal_data(test_data_file, etr_factor = 0.5) par <- data$par expect_equal(par[1], 0) @@ -203,15 +199,13 @@ test_that("read_universal_data universal_data.csv - etr_factor 0.5", { }) test_that("read_universal_data universal_data.csv - fraction_photosystem > 1", { - test_data_file <- file.path(getwd(), "data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data.csv") expect_error(read_universal_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_universal_data universal_data.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) - }) + test_data_file <- testthat::test_path("data", "universal_data.csv") + data <- read_universal_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par expect_equal(par[1], 0) diff --git a/src/tests/testthat/test-relative_root_mean_squared_error.R b/src/tests/testthat/test-relative_root_mean_squared_error.R index 924cea7..026f461 100644 --- a/src/tests/testthat/test-relative_root_mean_squared_error.R +++ b/src/tests/testthat/test-relative_root_mean_squared_error.R @@ -1,15 +1,24 @@ -test_that("test-relative_root_mean_squared_error.R", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - etr_regression_data <- get_etr_regression_data_from_model_result(model_result) - result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) - - relative_root_mean_squared_error <- relative_root_mean_squared_error(result) - }) - - if (is_debian_or_ubuntu()) { - expect_equal(relative_root_mean_squared_error, 0.0331529227874065) - } +test_that("test-relative_root_mean_squared_error - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + etr_regression_data <- get_etr_regression_data_from_model_result(model_result) + result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) + + relative_root_mean_squared_error <- relative_root_mean_squared_error(result) + + expect_equal(relative_root_mean_squared_error, 0.0331529227874065) +}) + +test_that("test-relative_root_mean_squared_error", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + etr_regression_data <- get_etr_regression_data_from_model_result(model_result) + result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) + + relative_root_mean_squared_error <- relative_root_mean_squared_error(result) + expect_true(is.finite(relative_root_mean_squared_error)) }) diff --git a/src/tests/testthat/test-root_mean_squared_error.R b/src/tests/testthat/test-root_mean_squared_error.R index f18ff4c..8606069 100644 --- a/src/tests/testthat/test-root_mean_squared_error.R +++ b/src/tests/testthat/test-root_mean_squared_error.R @@ -1,15 +1,23 @@ -test_that("test-root_mean_squared_error.R", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - etr_regression_data <- get_etr_regression_data_from_model_result(model_result) - result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) - - root_mean_squared_error <- root_mean_squared_error(result) - }) - - if (is_debian_or_ubuntu()) { - expect_equal(root_mean_squared_error, 0.88523222) - } +test_that("test-root_mean_squared_error - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + etr_regression_data <- get_etr_regression_data_from_model_result(model_result) + result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) + + root_mean_squared_error <- root_mean_squared_error(result) + expect_equal(root_mean_squared_error, 0.88523222) +}) + +test_that("test-root_mean_squared_error", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + etr_regression_data <- get_etr_regression_data_from_model_result(model_result) + result <- get_etr_data_for_par_values(data, etr_regression_data, etr_2_type) + + root_mean_squared_error <- root_mean_squared_error(result) + expect_true(is.finite(root_mean_squared_error)) }) diff --git a/src/tests/testthat/test-universal_data_etr_I.R b/src/tests/testthat/test-universal_data_etr_I.R index 4f24680..3ec9e5e 100644 --- a/src/tests/testthat/test-universal_data_etr_I.R +++ b/src/tests/testthat/test-universal_data_etr_I.R @@ -1,93 +1,116 @@ +test_that("test-universal_data_etr_I - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "universal_data.csv") + data <- read_universal_data(test_data_file) + + eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) + platt <- platt_modified(platt_generate_regression_ETR_I(data)) + walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) + vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) + + expect_equal(eilers_peeters[["residual_sum_of_squares"]], 53.4454062) + # expect_equal(eilers_peeters[["a"]], 0.000001479) + # expect_equal(eilers_peeters[["b"]], 0.002444096) + expect_equal(eilers_peeters[["c"]], 2.898407831) + expect_equal(eilers_peeters[["d"]], NA_real_) + expect_equal(eilers_peeters[["alpha"]], 0.345017009) + expect_equal(eilers_peeters[["beta"]], NA_real_) + expect_equal(eilers_peeters[["etrmax_with_photoinhibition"]], 151.851986) + expect_equal(eilers_peeters[["etrmax_without_photoinhibition"]], NA_real_) + expect_equal(eilers_peeters[["ik_with_photoinhibition"]], 440.1289906) + expect_equal(eilers_peeters[["ik_without_photoinhibition"]], NA_real_) + expect_equal(eilers_peeters[["im_with_photoinhibition"]], 1399.769662) + expect_equal(eilers_peeters[["w"]], 1.18036237) + expect_equal(eilers_peeters[["ib"]], NA_real_) + expect_equal(eilers_peeters[["etrmax_with_without_ratio"]], NA_real_) + + expect_equal(platt[["residual_sum_of_squares"]], 55.4812913) + expect_equal(platt[["a"]], 242.02858) + expect_equal(platt[["b"]], 0.350792446) + expect_equal(platt[["c"]], 0.056258718) + expect_equal(platt[["d"]], NA_real_) + expect_equal(platt[["alpha"]], 0.350792446) + expect_equal(platt[["beta"]], 0.056258718) + expect_equal(platt[["etrmax_with_photoinhibition"]], 151.8557330) + expect_equal(platt[["etrmax_without_photoinhibition"]], 242.02858) + expect_equal(platt[["ik_with_photoinhibition"]], 432.893395) + expect_equal(platt[["ik_without_photoinhibition"]], 689.94810) + expect_equal(platt[["im_with_photoinhibition"]], 1365.39202) + expect_equal(platt[["w"]], NA_real_) + expect_equal(platt[["ib"]], 4302.0636) + expect_equal(platt[["etrmax_with_without_ratio"]], 1.59380602) + + expect_equal(walsby[["residual_sum_of_squares"]], 55.5823146) + expect_equal(walsby[["a"]], 221.237830) + expect_equal(walsby[["b"]], 0.387249932) + expect_equal(walsby[["c"]], -0.035964258) + expect_equal(walsby[["d"]], NA_real_) + expect_equal(walsby[["alpha"]], 0.387249932) + expect_equal(walsby[["beta"]], -0.035964258) + expect_equal(walsby[["etrmax_with_photoinhibition"]], 151.8614464) + expect_equal(walsby[["etrmax_without_photoinhibition"]], 221.237830) + expect_equal(walsby[["ik_with_photoinhibition"]], 392.15358) + expect_equal(walsby[["ik_without_photoinhibition"]], 571.305017) + expect_equal(walsby[["im_with_photoinhibition"]], 1358.0) + expect_equal(walsby[["w"]], NA_real_) + expect_equal(walsby[["ib"]], NA_real_) + expect_equal(walsby[["etrmax_with_without_ratio"]], 1.456840002) + + expect_equal(vollenweider[["residual_sum_of_squares"]], 55.4621712) + expect_equal(vollenweider[["a"]], 191.5243754) + # expect_equal(vollenweider[["b"]], 0.001864811) + # expect_equal(vollenweider[["c"]], 0.00001772) + expect_equal(vollenweider[["d"]], 0.067483929) + expect_equal(vollenweider[["alpha"]], 0.31224738) + expect_equal(vollenweider[["beta"]], NA_real_) + expect_equal(vollenweider[["etrmax_with_photoinhibition"]], 152.615751) + expect_equal(vollenweider[["etrmax_without_photoinhibition"]], 191.5243754) + expect_equal(vollenweider[["ik_with_photoinhibition"]], 488.76551) + expect_equal(vollenweider[["ik_without_photoinhibition"]], 613.37384) + expect_equal(vollenweider[["im_with_photoinhibition"]], 1420.0) + expect_equal(vollenweider[["w"]], NA_real_) + expect_equal(vollenweider[["ib"]], NA_real_) + expect_equal(vollenweider[["etrmax_with_without_ratio"]], 1.254945) +}) + test_that("test-universal_data_etr_I", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "universal_data.csv") - data <- read_universal_data(test_data_file) + test_data_file <- testthat::test_path("data", "universal_data.csv") + data <- read_universal_data(test_data_file) - eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) - platt <- platt_modified(platt_generate_regression_ETR_I(data)) - walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) - vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) + eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) + expect_no_error(validate_model_result(eilers_peeters)) - if (is_debian_or_ubuntu()) { - expect_equal(eilers_peeters[["residual_sum_of_squares"]], 53.4454062) - # expect_equal(eilers_peeters[["a"]], 0.000001479) - # expect_equal(eilers_peeters[["b"]], 0.002444096) - expect_equal(eilers_peeters[["c"]], 2.898407831) - expect_equal(eilers_peeters[["d"]], NA_real_) - expect_equal(eilers_peeters[["alpha"]], 0.345017009) - expect_equal(eilers_peeters[["beta"]], NA_real_) - expect_equal(eilers_peeters[["etrmax_with_photoinhibition"]], 151.851986) - expect_equal(eilers_peeters[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(eilers_peeters[["ik_with_photoinhibition"]], 440.1289906) - expect_equal(eilers_peeters[["ik_without_photoinhibition"]], NA_real_) - expect_equal(eilers_peeters[["im_with_photoinhibition"]], 1399.769662) - expect_equal(eilers_peeters[["w"]], 1.18036237) - expect_equal(eilers_peeters[["ib"]], NA_real_) - expect_equal(eilers_peeters[["etrmax_with_without_ratio"]], NA_real_) - } + platt <- platt_modified(platt_generate_regression_ETR_I(data)) + expect_no_error(validate_model_result(platt)) - if (is_debian_or_ubuntu()) { - expect_equal(platt[["residual_sum_of_squares"]], 55.4812913) - expect_equal(platt[["a"]], 242.02858) - expect_equal(platt[["b"]], 0.350792446) - expect_equal(platt[["c"]], 0.056258718) - expect_equal(platt[["d"]], NA_real_) - expect_equal(platt[["alpha"]], 0.350792446) - expect_equal(platt[["beta"]], 0.056258718) - expect_equal(platt[["etrmax_with_photoinhibition"]], 151.8557330) - expect_equal(platt[["etrmax_without_photoinhibition"]], 242.02858) - expect_equal(platt[["ik_with_photoinhibition"]], 432.893395) - expect_equal(platt[["ik_without_photoinhibition"]], 689.94810) - expect_equal(platt[["im_with_photoinhibition"]], 1365.39202) - expect_equal(platt[["w"]], NA_real_) - expect_equal(platt[["ib"]], 4302.0636) - expect_equal(platt[["etrmax_with_without_ratio"]], 1.59380602) - } + walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) + expect_no_error(validate_model_result(walsby)) + + vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) + expect_no_error(validate_model_result(vollenweider)) +}) - if (is_debian_or_ubuntu()) { - expect_equal(walsby[["residual_sum_of_squares"]], 55.5823146) - expect_equal(walsby[["a"]], 221.237830) - expect_equal(walsby[["b"]], 0.387249932) - expect_equal(walsby[["c"]], -0.035964258) - expect_equal(walsby[["d"]], NA_real_) - expect_equal(walsby[["alpha"]], 0.387249932) - expect_equal(walsby[["beta"]], -0.035964258) - expect_equal(walsby[["etrmax_with_photoinhibition"]], 151.8614464) - expect_equal(walsby[["etrmax_without_photoinhibition"]], 221.237830) - expect_equal(walsby[["ik_with_photoinhibition"]], 392.15358) - expect_equal(walsby[["ik_without_photoinhibition"]], 571.305017) - expect_equal(walsby[["im_with_photoinhibition"]], 1358.0) - expect_equal(walsby[["w"]], NA_real_) - expect_equal(walsby[["ib"]], NA_real_) - expect_equal(walsby[["etrmax_with_without_ratio"]], 1.456840002) - } +test_that("test-universal_data_etr_I plot", { + test_data_file <- testthat::test_path("data", "universal_data.csv") + data <- read_universal_data(test_data_file) - if (is_debian_or_ubuntu()) { - expect_equal(vollenweider[["residual_sum_of_squares"]], 55.4621712) - expect_equal(vollenweider[["a"]], 191.5243754) - # expect_equal(vollenweider[["b"]], 0.001864811) - # expect_equal(vollenweider[["c"]], 0.00001772) - expect_equal(vollenweider[["d"]], 0.067483929) - expect_equal(vollenweider[["alpha"]], 0.31224738) - expect_equal(vollenweider[["beta"]], NA_real_) - expect_equal(vollenweider[["etrmax_with_photoinhibition"]], 152.615751) - expect_equal(vollenweider[["etrmax_without_photoinhibition"]], 191.5243754) - expect_equal(vollenweider[["ik_with_photoinhibition"]], 488.76551) - expect_equal(vollenweider[["ik_without_photoinhibition"]], 613.37384) - expect_equal(vollenweider[["im_with_photoinhibition"]], 1420.0) - expect_equal(vollenweider[["w"]], NA_real_) - expect_equal(vollenweider[["ib"]], NA_real_) - expect_equal(vollenweider[["etrmax_with_without_ratio"]], 1.254945) - } + eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) + platt <- platt_modified(platt_generate_regression_ETR_I(data)) + walsby <- walsby_modified(walsby_generate_regression_ETR_I(data)) + vollenweider <- vollenweider_modified(vollenweider_generate_regression_ETR_I(data)) - plot <- combo_plot_control( - "test-intermediate-table_etr_I.csv", - data, - list(eilers_peeters, platt, walsby, vollenweider), - list("eilers_peeters", "platt", "walsby", "vollenweider"), - list(color_eilers_peeters, color_platt, color_walsby, color_vollenweider) - ) + plot <- combo_plot_control( + "test-intermediate-table_etr_I.csv", + data, + list(eilers_peeters, platt, walsby, vollenweider), + list("eilers_peeters", "platt", "walsby", "vollenweider"), + list(color_eilers_peeters, color_platt, color_walsby, color_vollenweider) + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - ggplot2::ggsave("results/test-intermediate-table_etr_I.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1600, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-intermediate-table_etr_I.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1600, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-vollenweider_etr_I.R b/src/tests/testthat/test-vollenweider_etr_I.R index 88df054..8d02dec 100644 --- a/src/tests/testthat/test-vollenweider_etr_I.R +++ b/src/tests/testthat/test-vollenweider_etr_I.R @@ -1,79 +1,98 @@ -test_that("test-vollenweider_etr_I generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) - }) +test_that("test-vollenweider_etr_I generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + + expect_equal(model_result[["residual_sum_of_squares"]], 55.4621712) + expect_equal(model_result[["pmax"]], 191.5243754) + # expect_equal(model_result[["a"]], 0.001864811) + # expect_equal(model_result[["alpha"]], 0.00001772) + expect_equal(model_result[["n"]], 0.067483929) + expect_equal(model_result[["ik"]], 613.37384) + expect_equal(model_result[["popt"]], 152.615751) + expect_equal(model_result[["iik"]], 488.76551) + expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.254945) +}) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.4621712) - expect_equal(model_result[["pmax"]], 191.5243754) - # expect_equal(model_result[["a"]], 0.001864811) - # expect_equal(model_result[["alpha"]], 0.00001772) - expect_equal(model_result[["n"]], 0.067483929) - expect_equal(model_result[["ik"]], 613.37384) - expect_equal(model_result[["popt"]], 152.615751) - expect_equal(model_result[["iik"]], 488.76551) - expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.254945) - } +test_that("test-vollenweider_etr_I generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) }) test_that("test-vollenweider_etr_I control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + + plot <- plot_control( + data, + model_result, + "vollenweider ETR I 20240925.csv", + color_vollenweider + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "vollenweider ETR I 20240925.csv", - color_vollenweider - ) - ggplot2::ggsave("results/test-vollenweider_etr_I control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-vollenweider_etr_I control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) + +test_that("test-vollenweider_etr_I generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + model_result <- vollenweider_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 55.4621712) + expect_equal(model_result[["a"]], 191.5243754) + # expect_equal(model_result[["b"]], 0.001864811) + # expect_equal(model_result[["c"]], 0.00001772) + expect_equal(model_result[["d"]], 0.067483929) + expect_equal(model_result[["alpha"]], 0.31224738) + expect_equal(model_result[["beta"]], NA_real_) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 152.615751) + expect_equal(model_result[["etrmax_without_photoinhibition"]], 191.5243754) + expect_equal(model_result[["ik_with_photoinhibition"]], 488.76551) + expect_equal(model_result[["ik_without_photoinhibition"]], 613.37384) + expect_equal(model_result[["im_with_photoinhibition"]], 1420.0) + expect_equal(model_result[["w"]], NA_real_) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], 1.254945) }) test_that("test-vollenweider_etr_I generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) - model_result <- vollenweider_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.4621712) - expect_equal(model_result[["a"]], 191.5243754) - # expect_equal(model_result[["b"]], 0.001864811) - # expect_equal(model_result[["c"]], 0.00001772) - expect_equal(model_result[["d"]], 0.067483929) - expect_equal(model_result[["alpha"]], 0.31224738) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 152.615751) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 191.5243754) - expect_equal(model_result[["ik_with_photoinhibition"]], 488.76551) - expect_equal(model_result[["ik_without_photoinhibition"]], 613.37384) - expect_equal(model_result[["im_with_photoinhibition"]], 1420.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.254945) - } + model_result <- vollenweider_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-vollenweider_etr_I modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_I(data) - model_result <- vollenweider_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_I(data) + model_result <- vollenweider_modified(model_result) + + plot <- plot_control( + data, + model_result, + "vollenweider ETR I modified 20240925.csv", + color_vollenweider + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "vollenweider ETR I modified 20240925.csv", - color_vollenweider - ) - ggplot2::ggsave("results/test-vollenweider_etr_I modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-vollenweider_etr_I modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-vollenweider_etr_II.R b/src/tests/testthat/test-vollenweider_etr_II.R index f7f2039..f3836a4 100644 --- a/src/tests/testthat/test-vollenweider_etr_II.R +++ b/src/tests/testthat/test-vollenweider_etr_II.R @@ -1,79 +1,99 @@ -test_that("test-vollenweider_etr_II generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) - }) +test_that("test-vollenweider_etr_II generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + + expect_equal(model_result[["residual_sum_of_squares"]], 3.0153935) + expect_equal(model_result[["pmax"]], 52.752059) + # expect_equal(model_result[["a"]], 0.002845961) + # expect_equal(model_result[["alpha"]], -0.000378034) + expect_equal(model_result[["n"]], 47.8354111) + expect_equal(model_result[["ik"]], 345.86949) + expect_equal(model_result[["popt"]], 44.1785457) + expect_equal(model_result[["iik"]], 289.657149) + expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.194065095) +}) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 3.0153935) - expect_equal(model_result[["pmax"]], 52.752059) - # expect_equal(model_result[["a"]], 0.002845961) - # expect_equal(model_result[["alpha"]], -0.000378034) - expect_equal(model_result[["n"]], 47.8354111) - expect_equal(model_result[["ik"]], 345.86949) - expect_equal(model_result[["popt"]], 44.1785457) - expect_equal(model_result[["iik"]], 289.657149) - expect_equal(model_result[["pmax_popt_and_ik_iik_ratio"]], 1.194065095) - } +test_that("test-vollenweider_etr_II generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) }) test_that("test-vollenweider_etr_II control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + + plot <- plot_control( + data, + model_result, + "vollenweider ETR II 20240925.csv", + color_vollenweider + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "vollenweider ETR II 20240925.csv", - color_vollenweider - ) - ggplot2::ggsave("results/test-vollenweider_etr_II control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-vollenweider_etr_II control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) + +test_that("test-vollenweider_etr_II generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + model_result <- vollenweider_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 3.0153935) + expect_equal(model_result[["a"]], 52.752059) + # expect_equal(model_result[["b"]], 0.002845961) + # expect_equal(model_result[["c"]], -0.000378034) + expect_equal(model_result[["d"]], 47.8354111) + expect_equal(model_result[["alpha"]], 0.15252013) + expect_equal(model_result[["beta"]], NA_real_) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.1785457) + expect_equal(model_result[["etrmax_without_photoinhibition"]], 52.752059) + expect_equal(model_result[["ik_with_photoinhibition"]], 289.657149) + expect_equal(model_result[["ik_without_photoinhibition"]], 345.86949) + expect_equal(model_result[["im_with_photoinhibition"]], 767.0) + expect_equal(model_result[["w"]], NA_real_) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], 1.194065095) }) test_that("test-vollenweider_etr_II generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) - model_result <- vollenweider_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + + model_result <- vollenweider_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 3.0153935) - expect_equal(model_result[["a"]], 52.752059) - # expect_equal(model_result[["b"]], 0.002845961) - # expect_equal(model_result[["c"]], -0.000378034) - expect_equal(model_result[["d"]], 47.8354111) - expect_equal(model_result[["alpha"]], 0.15252013) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.1785457) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 52.752059) - expect_equal(model_result[["ik_with_photoinhibition"]], 289.657149) - expect_equal(model_result[["ik_without_photoinhibition"]], 345.86949) - expect_equal(model_result[["im_with_photoinhibition"]], 767.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.194065095) - } + model_result <- vollenweider_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-vollenweider_etr_II modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- vollenweider_generate_regression_ETR_II(data) - model_result <- vollenweider_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- vollenweider_generate_regression_ETR_II(data) + model_result <- vollenweider_modified(model_result) + + plot <- plot_control( + data, + model_result, + "vollenweider ETR II modified 20240925.csv", + color_vollenweider + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "vollenweider ETR II modified 20240925.csv", - color_vollenweider - ) - ggplot2::ggsave("results/test-vollenweider_etr_II modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-vollenweider_etr_II modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-walsby_etr_I.R b/src/tests/testthat/test-walsby_etr_I.R index bb41449..daf206b 100644 --- a/src/tests/testthat/test-walsby_etr_I.R +++ b/src/tests/testthat/test-walsby_etr_I.R @@ -1,75 +1,94 @@ -test_that("test-walsby_etr_I generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) - }) +test_that("test-walsby_etr_I generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + + expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) + expect_equal(model_result[["etr_max"]], 221.237830) + expect_equal(model_result[["alpha"]], 0.387249932) + expect_equal(model_result[["beta"]], -0.035964258) +}) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) - expect_equal(model_result[["etr_max"]], 221.237830) - expect_equal(model_result[["alpha"]], 0.387249932) - expect_equal(model_result[["beta"]], -0.035964258) - } +test_that("test-walsby_etr_I generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) }) test_that("test-walsby_etr_I control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) - plot <- plot_control( - data, - model_result, - "walsby ETR I 20240925.csv", - color_platt - ) + plot <- plot_control( + data, + model_result, + "walsby ETR I 20240925.csv", + color_platt + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - ggplot2::ggsave("results/test-walsby_etr_I control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-walsby_etr_I control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) + +test_that("test-walsby_etr_I generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + model_result <- walsby_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) + expect_equal(model_result[["a"]], 221.237830) + expect_equal(model_result[["b"]], 0.387249932) + expect_equal(model_result[["c"]], -0.035964258) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.387249932) + expect_equal(model_result[["beta"]], -0.035964258) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.8614464) + expect_equal(model_result[["etrmax_without_photoinhibition"]], 221.237830) + expect_equal(model_result[["ik_with_photoinhibition"]], 392.15358) + expect_equal(model_result[["ik_without_photoinhibition"]], 571.305017) + expect_equal(model_result[["im_with_photoinhibition"]], 1358.0) + expect_equal(model_result[["w"]], NA_real_) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], 1.456840002) }) test_that("test-walsby_etr_I generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) - model_result <- walsby_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 55.5823146) - expect_equal(model_result[["a"]], 221.237830) - expect_equal(model_result[["b"]], 0.387249932) - expect_equal(model_result[["c"]], -0.035964258) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.387249932) - expect_equal(model_result[["beta"]], -0.035964258) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 151.8614464) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 221.237830) - expect_equal(model_result[["ik_with_photoinhibition"]], 392.15358) - expect_equal(model_result[["ik_without_photoinhibition"]], 571.305017) - expect_equal(model_result[["im_with_photoinhibition"]], 1358.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.456840002) - } + model_result <- walsby_generate_regression_ETR_I(data) + expect_no_error(validate_model_result(model_result)) + + model_result <- walsby_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-walsby_etr_I modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_I(data) - model_result <- walsby_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_I(data) + model_result <- walsby_modified(model_result) + + plot <- plot_control( + data, + model_result, + "walsby ETR I modified 20240925.csv", + color_platt + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "walsby ETR I modified 20240925.csv", - color_platt - ) - ggplot2::ggsave("results/test-walsby_etr_I modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-walsby_etr_I modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-walsby_etr_II.R b/src/tests/testthat/test-walsby_etr_II.R index b37de97..067549c 100644 --- a/src/tests/testthat/test-walsby_etr_II.R +++ b/src/tests/testthat/test-walsby_etr_II.R @@ -1,75 +1,94 @@ -test_that("test-walsby_etr_II generate regression 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - }) +test_that("test-walsby_etr_II generate regression 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) + expect_equal(model_result[["etr_max"]], 64.620494) + expect_equal(model_result[["alpha"]], 0.197966245) + expect_equal(model_result[["beta"]], -0.018109015) +}) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) - expect_equal(model_result[["etr_max"]], 64.620494) - expect_equal(model_result[["alpha"]], 0.197966245) - expect_equal(model_result[["beta"]], -0.018109015) - } +test_that("test-walsby_etr_II generate regression 20240925.csv", { + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) }) test_that("test-walsby_etr_II control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + + plot <- plot_control( + data, + model_result, + "walsby ETR II 20240925.csv", + color_walsby + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "walsby ETR II 20240925.csv", - color_walsby - ) - ggplot2::ggsave("results/test-walsby_etr_II control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-walsby_etr_II control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) +}) + +test_that("test-walsby_etr_II generate regression modified 20240925.csv - linux", { + skip_if_not(is_debian_or_ubuntu()) + + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + model_result <- walsby_modified(model_result) + + expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) + expect_equal(model_result[["a"]], 64.620494) + expect_equal(model_result[["b"]], 0.197966245) + expect_equal(model_result[["c"]], -0.018109015) + expect_equal(model_result[["d"]], NA_real_) + expect_equal(model_result[["alpha"]], 0.197966245) + expect_equal(model_result[["beta"]], -0.018109015) + expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.5716318) + expect_equal(model_result[["etrmax_without_photoinhibition"]], 64.620494) + expect_equal(model_result[["ik_with_photoinhibition"]], 225.147635) + expect_equal(model_result[["ik_without_photoinhibition"]], 326.42178) + expect_equal(model_result[["im_with_photoinhibition"]], 781.0) + expect_equal(model_result[["w"]], NA_real_) + expect_equal(model_result[["ib"]], NA_real_) + expect_equal(model_result[["etrmax_with_without_ratio"]], 1.44981217) }) test_that("test-walsby_etr_II generate regression modified 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - model_result <- walsby_modified(model_result) - }) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) - if (is_debian_or_ubuntu()) { - expect_equal(model_result[["residual_sum_of_squares"]], 13.3218134) - expect_equal(model_result[["a"]], 64.620494) - expect_equal(model_result[["b"]], 0.197966245) - expect_equal(model_result[["c"]], -0.018109015) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.197966245) - expect_equal(model_result[["beta"]], -0.018109015) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 44.5716318) - expect_equal(model_result[["etrmax_without_photoinhibition"]], 64.620494) - expect_equal(model_result[["ik_with_photoinhibition"]], 225.147635) - expect_equal(model_result[["ik_without_photoinhibition"]], 326.42178) - expect_equal(model_result[["im_with_photoinhibition"]], 781.0) - expect_equal(model_result[["w"]], NA_real_) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_with_without_ratio"]], 1.44981217) - } + model_result <- walsby_generate_regression_ETR_II(data) + expect_no_error(validate_model_result(model_result)) + + model_result <- walsby_modified(model_result) + expect_no_error(validate_modified_model_result(model_result)) }) test_that("test-walsby_etr_II modified control plot 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - model_result <- walsby_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + model_result <- walsby_modified(model_result) + + plot <- plot_control( + data, + model_result, + "walsby ETR II modified 20240925.csv", + color_walsby + ) + expect_s3_class(plot, "ggplot") + expect_gt(length(plot$layers), 0) - plot <- plot_control( - data, - model_result, - "walsby ETR II modified 20240925.csv", - color_walsby - ) - ggplot2::ggsave("results/test-walsby_etr_II modified control plot 20240925.jpg", create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - }) + out <- file.path("results", "test-walsby_etr_II modified control plot 20240925.jpg") + ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) + expect_true(file.exists(out)) }) diff --git a/src/tests/testthat/test-write_model_result_csv.R b/src/tests/testthat/test-write_model_result_csv.R index 24c1527..ba54203 100644 --- a/src/tests/testthat/test-write_model_result_csv.R +++ b/src/tests/testthat/test-write_model_result_csv.R @@ -1,108 +1,104 @@ test_that("test-write_model_result_csv - walsby_modified - 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) - model_result <- walsby_modified(model_result) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) + model_result <- walsby_modified(model_result) - result_dir <- file.path(getwd(), "results") - dir.create(result_dir, showWarnings = FALSE) + result_dir <- testthat::test_path("results") + dir.create(result_dir, showWarnings = FALSE) - model_result_csv_path <- file.path(result_dir, "20240925_model_result.csv") - raw_data_csv_path <- file.path(result_dir, "20240925_raw_data.csv") - regression_data_csv_path <- file.path(result_dir, "20240925_regression_data.csv") - unlink(model_result_csv_path) - unlink(raw_data_csv_path) - unlink(regression_data_csv_path) + model_result_csv_path <- file.path(result_dir, "20240925_model_result.csv") + raw_data_csv_path <- file.path(result_dir, "20240925_raw_data.csv") + regression_data_csv_path <- file.path(result_dir, "20240925_regression_data.csv") + unlink(model_result_csv_path) + unlink(raw_data_csv_path) + unlink(regression_data_csv_path) - write_model_result_csv( - result_dir, - "20240925", - data, - model_result - ) + write_model_result_csv( + result_dir, + "20240925", + data, + model_result + ) - model_result_csv <- read.csv( - file = model_result_csv_path, - colClasses = "numeric" - ) - expect_equal(model_result_csv$a, model_result$a) - expect_equal(model_result_csv$b, model_result$b) - expect_equal(model_result_csv$c, model_result$c) - expect_equal(model_result_csv$d, model_result$d) - expect_equal(model_result_csv$alpha, model_result$alpha) - expect_equal(model_result_csv$beta, model_result$beta) - expect_equal(model_result_csv$etrmax_with_photoinhibition, model_result$etrmax_with_photoinhibition) - expect_equal(model_result_csv$etrmax_without_photoinhibition, model_result$etrmax_without_photoinhibition) - expect_equal(model_result_csv$im_with_photoinhibition, model_result$im_with_photoinhibition) - expect_equal(model_result_csv$w, model_result$w) - expect_equal(model_result_csv$ib, model_result$ib) - expect_equal(model_result_csv$etrmax_with_without_ratio, model_result$etrmax_with_without_ratio) + model_result_csv <- read.csv( + file = model_result_csv_path, + colClasses = "numeric" + ) + expect_equal(model_result_csv$a, model_result$a) + expect_equal(model_result_csv$b, model_result$b) + expect_equal(model_result_csv$c, model_result$c) + expect_equal(model_result_csv$d, model_result$d) + expect_equal(model_result_csv$alpha, model_result$alpha) + expect_equal(model_result_csv$beta, model_result$beta) + expect_equal(model_result_csv$etrmax_with_photoinhibition, model_result$etrmax_with_photoinhibition) + expect_equal(model_result_csv$etrmax_without_photoinhibition, model_result$etrmax_without_photoinhibition) + expect_equal(model_result_csv$im_with_photoinhibition, model_result$im_with_photoinhibition) + expect_equal(model_result_csv$w, model_result$w) + expect_equal(model_result_csv$ib, model_result$ib) + expect_equal(model_result_csv$etrmax_with_without_ratio, model_result$etrmax_with_without_ratio) - raw_data_csv <- read.csv( - file = raw_data_csv_path, - colClasses = "numeric" - ) - expect_equal(as.data.frame(raw_data_csv), as.data.frame(data)) + raw_data_csv <- read.csv( + file = raw_data_csv_path, + colClasses = "numeric" + ) + expect_equal(as.data.frame(raw_data_csv), as.data.frame(data)) - regression_data_csv <- read.csv( - file = regression_data_csv_path, - colClasses = "numeric" - ) - expect_equal(as.data.frame(regression_data_csv), as.data.frame(model_result$etr_regression_data)) - }) + regression_data_csv <- read.csv( + file = regression_data_csv_path, + colClasses = "numeric" + ) + expect_equal(as.data.frame(regression_data_csv), as.data.frame(model_result$etr_regression_data)) }) test_that("test-write_model_result_csv - walsby - 20240925.csv", { - expect_no_error({ - test_data_file <- file.path(getwd(), "data", "20240925.csv") - data <- read_dual_pam_data(test_data_file) - model_result <- walsby_generate_regression_ETR_II(data) + test_data_file <- testthat::test_path("data", "20240925.csv") + data <- read_dual_pam_data(test_data_file) + model_result <- walsby_generate_regression_ETR_II(data) - result_dir <- file.path(getwd(), "results") - dir.create(result_dir, showWarnings = FALSE) + result_dir <- testthat::test_path("results") + dir.create(result_dir, showWarnings = FALSE) - model_result_csv_path <- file.path(result_dir, "20240925_model_result.csv") - raw_data_csv_path <- file.path(result_dir, "20240925_raw_data.csv") - regression_data_csv_path <- file.path(result_dir, "20240925_regression_data.csv") - unlink(model_result_csv_path) - unlink(raw_data_csv_path) - unlink(regression_data_csv_path) + model_result_csv_path <- file.path(result_dir, "20240925_model_result.csv") + raw_data_csv_path <- file.path(result_dir, "20240925_raw_data.csv") + regression_data_csv_path <- file.path(result_dir, "20240925_regression_data.csv") + unlink(model_result_csv_path) + unlink(raw_data_csv_path) + unlink(regression_data_csv_path) - write_model_result_csv( - result_dir, - "20240925", - data, - model_result - ) + write_model_result_csv( + result_dir, + "20240925", + data, + model_result + ) - model_result_csv <- read.csv( - file = model_result_csv_path, - colClasses = "numeric" - ) - expect_equal(model_result_csv$a, model_result$a) - expect_equal(model_result_csv$b, model_result$b) - expect_equal(model_result_csv$c, model_result$c) - expect_equal(model_result_csv$d, model_result$d) - expect_equal(model_result_csv$alpha, model_result$alpha) - expect_equal(model_result_csv$beta, model_result$beta) - expect_equal(model_result_csv$etrmax_with_photoinhibition, model_result$etrmax_with_photoinhibition) - expect_equal(model_result_csv$etrmax_without_photoinhibition, model_result$etrmax_without_photoinhibition) - expect_equal(model_result_csv$im_with_photoinhibition, model_result$im_with_photoinhibition) - expect_equal(model_result_csv$w, model_result$w) - expect_equal(model_result_csv$ib, model_result$ib) - expect_equal(model_result_csv$etrmax_with_without_ratio, model_result$etrmax_with_without_ratio) + model_result_csv <- read.csv( + file = model_result_csv_path, + colClasses = "numeric" + ) + expect_equal(model_result_csv$a, model_result$a) + expect_equal(model_result_csv$b, model_result$b) + expect_equal(model_result_csv$c, model_result$c) + expect_equal(model_result_csv$d, model_result$d) + expect_equal(model_result_csv$alpha, model_result$alpha) + expect_equal(model_result_csv$beta, model_result$beta) + expect_equal(model_result_csv$etrmax_with_photoinhibition, model_result$etrmax_with_photoinhibition) + expect_equal(model_result_csv$etrmax_without_photoinhibition, model_result$etrmax_without_photoinhibition) + expect_equal(model_result_csv$im_with_photoinhibition, model_result$im_with_photoinhibition) + expect_equal(model_result_csv$w, model_result$w) + expect_equal(model_result_csv$ib, model_result$ib) + expect_equal(model_result_csv$etrmax_with_without_ratio, model_result$etrmax_with_without_ratio) - raw_data_csv <- read.csv( - file = raw_data_csv_path, - colClasses = "numeric" - ) - expect_equal(as.data.frame(raw_data_csv), as.data.frame(data)) + raw_data_csv <- read.csv( + file = raw_data_csv_path, + colClasses = "numeric" + ) + expect_equal(as.data.frame(raw_data_csv), as.data.frame(data)) - regression_data_csv <- read.csv( - file = regression_data_csv_path, - colClasses = "numeric" - ) - expect_equal(as.data.frame(regression_data_csv), as.data.frame(model_result$etr_regression_data)) - }) + regression_data_csv <- read.csv( + file = regression_data_csv_path, + colClasses = "numeric" + ) + expect_equal(as.data.frame(regression_data_csv), as.data.frame(model_result$etr_regression_data)) })