From 17e154a6387f69cda4bc28a09733369ad29257da Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 22 Apr 2024 13:49:01 -0500 Subject: [PATCH] align r/test files for workflow happiness --- R/{equivocal_zone.R => equivocal-zone.R} | 0 ...ic_calibration.R => numeric-calibration.R} | 0 R/{numeric_range.R => numeric-range.R} | 0 ...dictions_custom.R => predictions-custom.R} | 0 R/{prob_threshold.R => prob-threshold.R} | 0 ...alibration.R => probability-calibration.R} | 0 R/{misc.R => utils.R} | 0 .../testthat/_snaps/validation-regression.md | 10 ------ ...-classification.md => validation-rules.md} | 12 ++++++- tests/testthat/test-validation-regression.R | 32 ------------------- ...assification.R => test-validation-rules.R} | 32 ++++++++++++++++++- 11 files changed, 42 insertions(+), 44 deletions(-) rename R/{equivocal_zone.R => equivocal-zone.R} (100%) rename R/{numeric_calibration.R => numeric-calibration.R} (100%) rename R/{numeric_range.R => numeric-range.R} (100%) rename R/{predictions_custom.R => predictions-custom.R} (100%) rename R/{prob_threshold.R => prob-threshold.R} (100%) rename R/{probability_calibration.R => probability-calibration.R} (100%) rename R/{misc.R => utils.R} (100%) delete mode 100644 tests/testthat/_snaps/validation-regression.md rename tests/testthat/_snaps/{validation-classification.md => validation-rules.md} (79%) delete mode 100644 tests/testthat/test-validation-regression.R rename tests/testthat/{test-validation-classification.R => test-validation-rules.R} (60%) diff --git a/R/equivocal_zone.R b/R/equivocal-zone.R similarity index 100% rename from R/equivocal_zone.R rename to R/equivocal-zone.R diff --git a/R/numeric_calibration.R b/R/numeric-calibration.R similarity index 100% rename from R/numeric_calibration.R rename to R/numeric-calibration.R diff --git a/R/numeric_range.R b/R/numeric-range.R similarity index 100% rename from R/numeric_range.R rename to R/numeric-range.R diff --git a/R/predictions_custom.R b/R/predictions-custom.R similarity index 100% rename from R/predictions_custom.R rename to R/predictions-custom.R diff --git a/R/prob_threshold.R b/R/prob-threshold.R similarity index 100% rename from R/prob_threshold.R rename to R/prob-threshold.R diff --git a/R/probability_calibration.R b/R/probability-calibration.R similarity index 100% rename from R/probability_calibration.R rename to R/probability-calibration.R diff --git a/R/misc.R b/R/utils.R similarity index 100% rename from R/misc.R rename to R/utils.R diff --git a/tests/testthat/_snaps/validation-regression.md b/tests/testthat/_snaps/validation-regression.md deleted file mode 100644 index 6073d02..0000000 --- a/tests/testthat/_snaps/validation-regression.md +++ /dev/null @@ -1,10 +0,0 @@ -# validation of regression operations - - Code - container(mode = "regression") %>% adjust_numeric_range(lower_limit = 2) %>% - adjust_numeric_calibration(dummy_reg_cal) %>% adjust_predictions_custom( - squared = .pred^2) - Condition - Error in `adjust_numeric_calibration()`: - ! Calibration should come before other operations. - diff --git a/tests/testthat/_snaps/validation-classification.md b/tests/testthat/_snaps/validation-rules.md similarity index 79% rename from tests/testthat/_snaps/validation-classification.md rename to tests/testthat/_snaps/validation-rules.md index 3b56ae9..a4ae358 100644 --- a/tests/testthat/_snaps/validation-classification.md +++ b/tests/testthat/_snaps/validation-rules.md @@ -1,4 +1,14 @@ -# validation of classification operations +# validation of operations (regression) + + Code + container(mode = "regression") %>% adjust_numeric_range(lower_limit = 2) %>% + adjust_numeric_calibration(dummy_reg_cal) %>% adjust_predictions_custom( + squared = .pred^2) + Condition + Error in `adjust_numeric_calibration()`: + ! Calibration should come before other operations. + +# validation of operations (classification) Code container(mode = "classification") %>% adjust_probability_threshold(threshold = 0.4) %>% diff --git a/tests/testthat/test-validation-regression.R b/tests/testthat/test-validation-regression.R deleted file mode 100644 index 5112a90..0000000 --- a/tests/testthat/test-validation-regression.R +++ /dev/null @@ -1,32 +0,0 @@ -test_that("validation of regression operations", { - - dummy_reg_cal <- list() - class(dummy_reg_cal) <- "cal_regression" - - expect_silent( - reg_ctr <- - container(mode = "regression") %>% - adjust_numeric_calibration(dummy_reg_cal) %>% - adjust_numeric_range(lower_limit = 2) %>% - adjust_predictions_custom(squared = .pred^2) - ) - - expect_snapshot( - container(mode = "regression") %>% - adjust_numeric_range(lower_limit = 2) %>% - adjust_numeric_calibration(dummy_reg_cal) %>% - adjust_predictions_custom(squared = .pred^2), - error = TRUE - ) - - # todo should we error if a mutate occurs beforehand? Can we detect if it - # modifies the prediction? - expect_silent( - reg_ctr <- - container(mode = "regression") %>% - adjust_predictions_custom(squared = .pred^2) %>% - adjust_numeric_calibration(dummy_reg_cal) %>% - adjust_numeric_range(lower_limit = 2) - ) - -}) diff --git a/tests/testthat/test-validation-classification.R b/tests/testthat/test-validation-rules.R similarity index 60% rename from tests/testthat/test-validation-classification.R rename to tests/testthat/test-validation-rules.R index 9ee71aa..c86cb1b 100644 --- a/tests/testthat/test-validation-classification.R +++ b/tests/testthat/test-validation-rules.R @@ -1,5 +1,35 @@ -test_that("validation of classification operations", { +test_that("validation of operations (regression)", { + dummy_reg_cal <- list() + class(dummy_reg_cal) <- "cal_regression" + expect_silent( + reg_ctr <- + container(mode = "regression") %>% + adjust_numeric_calibration(dummy_reg_cal) %>% + adjust_numeric_range(lower_limit = 2) %>% + adjust_predictions_custom(squared = .pred^2) + ) + + expect_snapshot( + container(mode = "regression") %>% + adjust_numeric_range(lower_limit = 2) %>% + adjust_numeric_calibration(dummy_reg_cal) %>% + adjust_predictions_custom(squared = .pred^2), + error = TRUE + ) + + # todo should we error if a mutate occurs beforehand? Can we detect if it + # modifies the prediction? + expect_silent( + reg_ctr <- + container(mode = "regression") %>% + adjust_predictions_custom(squared = .pred^2) %>% + adjust_numeric_calibration(dummy_reg_cal) %>% + adjust_numeric_range(lower_limit = 2) + ) +}) + +test_that("validation of operations (classification)", { dummy_cls_cal <- list() class(dummy_cls_cal) <- "cal_binary"