tests/testthat/test-dynamic_implementation_loading.R

test_that("sparse matrices trigger loading of sparseMatrixStats", {
  if (requireNamespace("Matrix", quietly = TRUE)) {
    # Make a matrix with different features
    mat <- matrix(rnorm(16 * 6), nrow = 16, ncol = 6)
    sp_mat <- as(mat, "dgCMatrix")
    expect_equal(colLogSumExps(sp_mat), colLogSumExps(mat))
  }
})


test_that("sparse matrices trigger loading of sparseMatrixStats", {
  if (requireNamespace("Matrix", quietly = TRUE)) {
    # Make a matrix with different features
    mat <- matrix(rnorm(16 * 6), nrow = 16, ncol = 6)
    sp_mat <- as(mat, "dgCMatrix")
    expect_equal(colVars(sp_mat), colVars(mat))
  }
})
Bioconductor/MatrixGenerics documentation built on April 19, 2024, 8:19 a.m.