File: test_bpaggregate.R

package info (click to toggle)
r-bioc-biocparallel 1.40.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,768 kB
  • sloc: cpp: 139; sh: 14; makefile: 8
file content (43 lines) | stat: -rw-r--r-- 1,153 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
message("Testing bpaggregate")

test_bpaggregate <- 
    function() 
{
    DEACTIVATED("Doesn't work on Debian autopkgtest infrastructure")

    x <- data.frame(a=1:10, b=10:1)
    by <- list(c(rep("a", 5), rep("b", 5)))
    simplify <- TRUE
    FUN <- mean

    x1 <- aggregate(x, by=by, FUN=FUN)
    param <- bpparam()
    bpworkers(param) <- 2
    x2 <- bpaggregate(x, by=by, FUN=FUN, BPPARAM=param, simplify=simplify)
    checkEquals(x1, x2)

    by[[2]] <- c(rep("c", 8), rep("d", 2))
    x1 <- aggregate(x, by=by, FUN=FUN)
    x2 <- bpaggregate(x, by=by, FUN=FUN, BPPARAM=param, simplify=simplify)
    checkEquals(x1, x2)

    closeAllConnections()
    TRUE
}

test_bpaggregate_formula <-
    function()
{
    f <- Sepal.Length ~ Species
    iris1 <- iris
    iris1$Species <-       # FIXME: bpaggregate doesn't respect factor
        as.character(iris1$Species) 
    x1 <- aggregate(f, data=iris1, FUN=sum)
    x2 <- bpaggregate(f, data = iris1, FUN = sum)
    checkEquals(x1, x2)

    iris1 <- iris1[sample(nrow(iris1)),]
    x3 <- aggregate(f, data=iris1, FUN=sum)
    x4 <- bpaggregate(f, data = iris1, FUN = sum)
    checkIdentical(x3, x4)
}