File: test_SparseArraySeed-class.R

package info (click to toggle)
r-bioc-delayedarray 0.24.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,480 kB
  • sloc: ansic: 727; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 744 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

test_SparseArraySeed_getters <- function()
{
    nzindex1 <- nzindex2 <- rbind(c(2,4,3), c(2,1,3), c(5,4,3), c(5,3,3),
                                  c(5,4,1), c(5,1,1), c(5,4,2), c(5,4,1))
    nzdata <- seq_len(nrow(nzindex1)) / 10
    sas <- SparseArraySeed(5:3, nzindex1, nzdata)

    checkIdentical(dim(sas), 5:3)
    checkIdentical(length(sas), 60L)
    storage.mode(nzindex2) <- "integer"
    checkIdentical(nzindex(sas), nzindex2)
    checkIdentical(nzdata(sas), nzdata)
}

test_dense2sparse_and_sparse2dense <- function()
{
    m <- matrix(c(5:-2, rep.int(c(0L, 99L), 11)), ncol=6)
    sas <- dense2sparse(m)
    checkTrue(is(sas, "SparseArraySeed"))
    checkIdentical(dim(sas), dim(m))
    checkIdentical(sparse2dense(sas), m)
}