File: test_RleArray-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 (63 lines) | stat: -rw-r--r-- 2,005 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

test_RleArray <- function()
{
    data <- Rle(1:200000, 125)
    A1 <- RleArray(data, c(62500, 400))
    A2 <- RleArray(data, c(62500, 400), chunksize=1e8)

    on.exit(suppressMessages(setAutoBlockSize()))
    suppressMessages(setAutoBlockSize(10e6))
    rs1 <- rowSums(A1)
    rs2 <- rowSums(A2)
    checkIdentical(rs1, rs2)
    cs1 <- colSums(A1)
    cs2 <- colSums(A2)
    checkIdentical(cs1, cs2)

    ## TODO: Add more tests...
}

test_long_RleArray <- function()
{
    data <- list(Rle(1:5000, 200000), Rle(1:20000, 12500), Rle(1:50000, 20000))
    A <- RleArray(data, dim=c(30000, 75000))
    checkTrue(validObject(A, complete=TRUE))
    checkTrue(is(seed(A), "ChunkedRleArraySeed"))

    ## TODO: Add more tests...
}

test_coercion_to_RleArray <- function()
{
    TYPES <- c("logical", "integer", "double", "complex", "character", "raw")
    for (type in TYPES) {
        x0 <- vector(type)
        from <- as(Rle(x0), "CompressedRleList")
        current <- as(from, "RleArray")
        checkTrue(is(current, "RleMatrix"))
        checkTrue(validObject(current, complete=TRUE))
        checkIdentical(c(0L, 0L), dim(current))
        checkIdentical(type, type(current))
        checkIdentical(matrix(x0, nrow=0, ncol=0), as.matrix(current))
    }

    from <- RleList(compress=FALSE)
    current <- as(from, "RleArray")
    checkTrue(is(current, "RleMatrix"))
    checkTrue(validObject(current, complete=TRUE))
    checkIdentical(c(0L, 0L), dim(current))
    checkIdentical("logical", type(current))
    checkIdentical(matrix(nrow=0, ncol=0), as.matrix(current))

    from <- RleList(A=Rle(1, 10), B=Rle(2, 10))
    current <- as(from, "RleArray")
    checkTrue(is(current, "RleMatrix"))
    checkTrue(validObject(current, complete=TRUE))
    checkIdentical(c(10L, 2L), dim(current))
    checkIdentical("double", type(current))
    checkIdentical(cbind(A=rep(1, 10), B=rep(2, 10)), as.matrix(current))

    from <- RleList(A=Rle(1, 10), B=Rle(2, 9))
    checkException(as(from, "RleArray"))
}