Skip to content

Commit

Permalink
feat: add boolean indexing tests to test-extract.R
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed2uiz committed Jan 23, 2024
1 parent 2352b6d commit 7a527bf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/testthat/test-extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,30 @@ test_that("character row/col indexing works", {
})

# ---------------------------------------------------------------------------- #
# Perform boolean indexing

boolean_row_index = c(rep(FALSE, nrow(dgc)-5), rep(TRUE,5))
dgc_subset = dgc[boolean_row_index,]
dbsm_subset = dbsm[boolean_row_index,]
dgc_db_subset = as_matrix(dbsm_subset)

test_that("boolean row indexing works", {
expect_equal(dgc_subset, dgc_db_subset)
})

boolean_col_index = c(rep(FALSE, ncol(dgc)-5), rep(TRUE,5))
dgc_subset = dgc[,boolean_col_index]
dbsm_subset = dbsm[,boolean_col_index]
dgc_db_subset = as_matrix(dbsm_subset)

test_that("boolean col indexing works", {
expect_equal(dgc_subset, dgc_db_subset)
})

dgc_subset = dgc[boolean_row_index,boolean_col_index]
dbsm_subset = dbsm[boolean_row_index,boolean_col_index]
dgc_db_subset = as_matrix(dbsm_subset)

test_that("boolean row/col indexing works", {
expect_equal(dgc_subset, dgc_db_subset)
})

0 comments on commit 7a527bf

Please sign in to comment.