-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for intersection utility,
Also protect against differences in the number of rows between the test and reference datasets when no intersection is performed.
- Loading branch information
Showing
2 changed files
with
16 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# library(testthat); library(SingleR); source("test-utils.R") | ||
|
||
test_that("intersection works as expected for edge cases", { | ||
out <- SingleR:::.create_intersection(c("A", "B", "C", "a"), LETTERS) | ||
expect_identical(out$test, 1:3) | ||
expect_identical(out$reference, 1:3) | ||
|
||
out <- SingleR:::.create_intersection(c("a", "Z", "b", "G", "c", "B", "d"), LETTERS) | ||
expect_identical(out$test, c(2L, 4L, 6L)) | ||
expect_identical(out$reference, c(26L, 7L, 2L)) | ||
|
||
out <- SingleR:::.create_intersection(c("y", "y", "x", "z", NA, "z", "x"), letters) | ||
expect_identical(out$test, c(1L, 3L, 4L)) | ||
expect_identical(out$reference, c(25L, 24L, 26L)) | ||
}) |