Skip to content

Commit 21ad7ae

Browse files
authored
Merge pull request #1113 from cmu-delphi/fb-package-label-debug-output
[fb-package] Modify output when debug flag is on
2 parents 85e4e8d + 2930bc2 commit 21ad7ae

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

facebook/delphiFacebook/R/contingency_run.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#'
99
#' @export
1010
run_contingency_tables <- function(params) {
11+
if (!is.null(params$debug) && params$debug) {
12+
debug_msg <- "!!!debug is on and the standard privacy threshold for sample size is disabled!!!"
13+
msg_plain(debug_msg)
14+
warning(debug_msg)
15+
}
16+
1117
if ( !is.null(params$aggs_in) ) {
1218
if ( !file.exists(params$aggs_in) ) {
1319
stop("requested aggregate-setting file does not exist")

facebook/delphiFacebook/R/contingency_write.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ get_file_name <- function(params, geo_type, groupby_vars) {
159159
paste(aggregation_type, collapse = "_"),
160160
sep = "_"
161161
)
162+
if (!is.null(params$debug) && params$debug) {
163+
file_name <- paste0("DebugOn-DoNotShare_", file_name)
164+
}
162165
file_name <- paste0(file_name, ".csv")
163166
return(file_name)
164167
}

facebook/delphiFacebook/unit-tests/testthat/test-contingency-write.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ test_that("testing write_contingency_tables command", {
5050
df <- read_csv(file.path(tdir, "20200510_20200516_weekly_state_tested.csv"))
5151
expect_equivalent(df, test_data)
5252
})
53+
54+
test_that("testing command to create output filenames", {
55+
params <- list(
56+
debug=TRUE,
57+
aggregate_range="month",
58+
start_date=as.Date("2021-01-01"),
59+
end_date=as.Date("2021-01-02")
60+
)
61+
out <- get_file_name(params, "nation", c("gender"))
62+
expected <- "DebugOn-DoNotShare_20210101_20210102_monthly_nation_gender.csv"
63+
64+
params$debug <- FALSE
65+
out <- get_file_name(params, "nation", c("gender", "race", "ethnicity"))
66+
expected <- "20210101_20210102_monthly_nation_ethnicity_gender_race.csv"
67+
})

0 commit comments

Comments
 (0)