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 Nov. 2, 2024, 4:13 a.m.