-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from OHDSI/fixNanMinCellValue
Censoring all values to NA where specified the minCellValue is NaN
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
test_that("enforceMinCellValue works as expected", { | ||
test_data <- data.frame( | ||
A = c(1, 2, 3, NA, 0) | ||
) | ||
result <- enforceMinCellValue(test_data, "A", 2) | ||
expect_equal(result$A, c(-2, 2, 3, NA, 0)) | ||
}) | ||
|
||
|
||
test_that("minCellValue handles bad inputs", { | ||
x <- data.frame(a = c(0.1, 0.002)) | ||
res <- enforceMinCellValue(x, "a", NaN) | ||
checkmate::expect_data_frame(res) | ||
expect_true(all(is.na(res$a))) | ||
}) |