-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added iteration seed as configuration parameter.
- Loading branch information
1 parent
931d985
commit ca63273
Showing
5 changed files
with
150 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Don't perform any further tests on CRAN due to running time. | ||
testthat::skip_on_cran() | ||
|
||
# Create data.table. | ||
data <- familiar:::test_create_good_data( | ||
outcome_type = "binomial", | ||
to_data_object = FALSE | ||
) | ||
|
||
# Check reproducibility of sample assignment ----------------------------------- | ||
|
||
# Create data assignment object without fixed seed. | ||
experiment_data_assignment_random <- familiar::precompute_data_assignment( | ||
data = data, | ||
experimental_design = "bs(fs+mb,3)", | ||
outcome_type = "binomial", | ||
outcome_column = "outcome", | ||
batch_id_column = "batch_id", | ||
sample_id_column = "sample_id", | ||
series_id_column = "series_id", | ||
class_levels = c("red", "green"), | ||
verbose = FALSE | ||
) | ||
|
||
# Create data assignment object with fixed seed. | ||
experiment_data_assignment_a <- familiar::precompute_data_assignment( | ||
data = data, | ||
experimental_design = "bs(fs+mb,3)", | ||
outcome_type = "binomial", | ||
outcome_column = "outcome", | ||
batch_id_column = "batch_id", | ||
sample_id_column = "sample_id", | ||
series_id_column = "series_id", | ||
class_levels = c("red", "green"), | ||
iteration_seed = 19L, | ||
verbose = FALSE | ||
) | ||
|
||
# Create data assignment object with fixed seed. | ||
experiment_data_assignment_b <- familiar::precompute_data_assignment( | ||
data = data, | ||
experimental_design = "bs(fs+mb,3)", | ||
outcome_type = "binomial", | ||
outcome_column = "outcome", | ||
batch_id_column = "batch_id", | ||
sample_id_column = "sample_id", | ||
series_id_column = "series_id", | ||
class_levels = c("red", "green"), | ||
iteration_seed = 19L, | ||
verbose = FALSE | ||
) | ||
|
||
# Create data assignment object with fixed seed. | ||
experiment_data_assignment_different <- familiar::precompute_data_assignment( | ||
data = data, | ||
experimental_design = "bs(fs+mb,3)", | ||
outcome_type = "binomial", | ||
outcome_column = "outcome", | ||
batch_id_column = "batch_id", | ||
sample_id_column = "sample_id", | ||
series_id_column = "series_id", | ||
class_levels = c("red", "green"), | ||
iteration_seed = 20L, | ||
verbose = FALSE | ||
) | ||
|
||
# Test that the same fixed seed leads to the same sample assignment. | ||
testthat::expect_equal( | ||
experiment_data_assignment_a@iteration_list, | ||
experiment_data_assignment_b@iteration_list, | ||
ignore_attr = TRUE | ||
) | ||
|
||
# Test that the random seed leads to a different sample assignment. | ||
testthat::expect_false(identical( | ||
experiment_data_assignment_random@iteration_list, | ||
experiment_data_assignment_a@iteration_list | ||
)) | ||
|
||
# Test that a different fixed seed leads to a different sample assignment. | ||
testthat::expect_false(identical( | ||
experiment_data_assignment_different@iteration_list, | ||
experiment_data_assignment_a@iteration_list | ||
)) |