diff --git a/NAMESPACE b/NAMESPACE index 53a3e0fd..42ef9c61 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,6 +12,7 @@ export(check_experiment) export(check_experiments) export(check_experiments_all_inference_models_are_unique) export(check_experiments_candidates_have_same_mcmcs) +export(check_gen_and_cand_exps_save_to_different_files) export(check_inference_conditions) export(check_init_pir_params) export(check_is_ns_beast2_pkg_installed) diff --git a/R/check_experiments.R b/R/check_experiments.R index c3d39259..d75ac2d0 100644 --- a/R/check_experiments.R +++ b/R/check_experiments.R @@ -53,7 +53,6 @@ check_experiments <- function( if (length(experiments) == 1) return() testit::assert(length(experiments) >= 2) - pirouette::check_candidates_save_to_same_files(experiments) pirouette::check_experiments_candidates_have_same_mcmcs(experiments) @@ -73,4 +72,5 @@ check_experiments <- function( stop("If multiple experiments, generative is either first or absent") } pirouette::check_experiments_all_inference_models_are_unique(experiments) + pirouette::check_gen_and_cand_exps_save_to_different_files(experiments) } diff --git a/R/check_gen_and_cand_save_to_different_files.R b/R/check_gen_and_cand_save_to_different_files.R new file mode 100644 index 00000000..549fd5c4 --- /dev/null +++ b/R/check_gen_and_cand_save_to_different_files.R @@ -0,0 +1,18 @@ +#' @export +check_gen_and_cand_exps_save_to_different_files <- function(experiments) { # nolint indeed a long function name + if (length(experiments) < 2) return() + if (experiments[[1]]$inference_conditions$model_type != "generative") { + return() + } + testthat::expect_equal( + experiments[[2]]$inference_conditions$model_type, + "candidate" + ) + if (experiments[[1]]$errors_filename == experiments[[2]]$errors_filename) { + stop( + "The errors filenames of generative and candidate experiments ", + "must differ. ", + "Actual value: ", experiments[[1]]$errors_filename + ) + } +} diff --git a/tests/testthat/test-check_experiments.R b/tests/testthat/test-check_experiments.R index 0d2a678c..c5e5f78c 100644 --- a/tests/testthat/test-check_experiments.R +++ b/tests/testthat/test-check_experiments.R @@ -67,7 +67,7 @@ test_that("correct order of experiments", { ) }) -test_that("same beast2_options_filenames and error fileanames in candidates", { +test_that("same beast2_options_filenames and error filenames in candidates", { if (rappdirs::app_dir()$os == "win") return() @@ -216,3 +216,18 @@ test_that("detect same model in two candidate models", { "All inference models must be unique" ) }) + +test_that("different error filenames between generative and candidate", { + + if (rappdirs::app_dir()$os == "win") return() + + experiments <- create_test_pir_params_setup( + has_candidate = TRUE + )$experiments + experiments[[1]]$errors_filename <- "errors.csv" + experiments[[2]]$errors_filename <- "errors.csv" + expect_error( + check_experiments(experiments), + "The errors filenames of generative and candidate experiments must differ" + ) +})