Skip to content

Commit

Permalink
Fix #402
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Feb 25, 2020
1 parent 5917fe6 commit 72b11e9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/check_experiments.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}
18 changes: 18 additions & 0 deletions R/check_gen_and_cand_save_to_different_files.R
Original file line number Diff line number Diff line change
@@ -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
)
}
}
17 changes: 16 additions & 1 deletion tests/testthat/test-check_experiments.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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"
)
})

0 comments on commit 72b11e9

Please sign in to comment.