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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
Author: Michael R. Crusoe <crusoe@debian.org>
Description: skip tests that use the unpackaged optional dependency 'chihaya'
Forwarded: not-needed
--- r-bioc-alabaster.matrix.orig/tests/testthat/test-stage-array.R
+++ r-bioc-alabaster.matrix/tests/testthat/test-stage-array.R
@@ -116,117 +116,6 @@
expect_equal(as.array(arr2), as.array(y))
})
-test_that("stageObject works with DelayedArrays with preserved operations", {
- dir <- tempfile()
- odir <- file.path(dir, experiment)
- dir.create(odir, recursive=TRUE)
-
- library(DelayedArray)
- x <- DelayedArray(arr)
- x <- log2(x / runif(nrow(x)) + 1)
-
- old <- preserveDelayedOperations(TRUE)
- info <- stageObject(x, dir, file.path(experiment, assay))
- preserveDelayedOperations(old)
- expect_match(info$`$schema`, "hdf5_delayed_array")
- expect_error(alabaster.base::.writeMetadata(info, dir=dir), NA)
-
- arr2 <- loadArray(info, project=dir)
- expect_equal(unname(as.array(arr2)), unname(as.array(x)))
-})
-
-test_that("stageObject works with DelayedArrays with local references", {
- dir <- tempfile()
- odir <- file.path(dir, experiment)
- dir.create(odir, recursive=TRUE)
-
- info <- stageObject(arr, dir, paste0(experiment, "/raw"))
- alabaster.base::.writeMetadata(info, dir=dir)
- raw.path <- info$path
-
- # Adding delayed operations.
- library(DelayedArray)
- x <- DelayedArray(arr)
- x <- log2(x / runif(nrow(x)) + 1)
-
- old <- preserveDelayedOperations(TRUE)
- info <- stageObject(x, dir, file.path(experiment, assay))
- preserveDelayedOperations(old)
-
- expect_match(info$`$schema`, "hdf5_delayed_array")
- expect_error(alabaster.base::.writeMetadata(info, dir=dir), NA)
-
- # Manually replacing the seed with a local reference.
- fpath <- file.path(dir, info$path)
- rhdf5::h5delete(fpath, "data/seed/seed/seed")
- rhdf5::h5createGroup(fpath, "data/seed/seed/seed")
- rhdf5::h5write(dim(arr), fpath, "data/seed/seed/seed/dimensions")
- rhdf5::h5write("integer", fpath, "data/seed/seed/seed/type")
- rhdf5::h5write(raw.path, fpath, "data/seed/seed/seed/path")
-
- {
- fhandle = rhdf5::H5Fopen(fpath, "H5F_ACC_RDWR")
- ghandle = rhdf5::H5Gopen(fhandle, "data/seed/seed/seed")
- rhdf5::h5writeAttribute("array", ghandle, "delayed_type", asScalar=TRUE)
- rhdf5::h5writeAttribute("custom alabaster local array", ghandle, "delayed_array", asScalar=TRUE)
- rhdf5::H5Gclose(ghandle)
- rhdf5::H5Fclose(fhandle)
- }
-
- # Now seeing if we can load it.
- arr2 <- loadArray(info, project=dir)
- expect_equal(unname(as.array(arr2)), unname(as.array(x)))
-})
-
-test_that("stageObject recycles existing HDF5Arrays", {
- dir <- tempfile()
- dir.create(dir, recursive=TRUE)
-
- library(HDF5Array)
- x <- as(matrix(runif(1000), 10, 100), "HDF5Array")
- rhdf5::h5write("foo", path(x), "bar") # injecting a little something to distinguish it from a rewritten file.
-
- {
- info <- stageObject(x, dir, "dense")
- expect_false(identical(file.size(path(x)), file.size(file.path(dir, info$path)))) # negative control that triggers the fallback.
- arr2 <- loadArray(info, project=dir)
- expect_equal(unname(as.array(arr2)), unname(as.array(x)))
- }
-
- old <- recycleHdf5Files(TRUE)
- on.exit(recycleHdf5Files(old))
-
- {
- info <- stageObject(x, dir, "dense2")
- expect_match(info$`$schema`, "hdf5_dense_array")
- expect_error(alabaster.base::.writeMetadata(info, dir=dir), NA)
- expect_identical(file.size(path(x)), file.size(file.path(dir, info$path))) # same file.
-
- arr2 <- loadArray(info, project=dir)
- expect_equal(unname(as.array(arr2)), unname(as.array(x)))
- }
-
- {
- y <- Matrix::rsparsematrix(20, 50, density=0.1)
- tmp <- tempfile(fileext=".h5")
- rhdf5::h5createFile(tmp)
- rhdf5::h5createGroup(tmp, "foo")
- rhdf5::h5write(y@p, tmp, "foo/indptr")
- rhdf5::h5write(y@i, tmp, "foo/indices")
- rhdf5::h5write(y@x, tmp, "foo/data")
- rhdf5::h5write(dim(y), tmp, "foo/shape")
- x <- H5SparseMatrix(tmp, "foo")
-
- info <- stageObject(x, dir, "sparse")
- expect_match(info$`$schema`, "hdf5_sparse_matrix")
- expect_error(alabaster.base::.writeMetadata(info, dir=dir), NA)
- expect_identical(file.size(path(x)), file.size(file.path(dir, info$path)))
-
- arr2 <- loadArray(info, project=dir)
- expect_equal(unname(as.array(arr2)), unname(as.array(x)))
- }
-})
-
test_that("reading arrays work with non-default NA placeholders", {
dir <- tempfile()
dir.create(dir, recursive=TRUE)
--- r-bioc-alabaster.matrix.orig/tests/testthat/test-stage-matrix.R
+++ r-bioc-alabaster.matrix/tests/testthat/test-stage-matrix.R
@@ -128,33 +128,3 @@
expect_identical(DelayedArray::type(mat2), "logical")
expect_identical(as.matrix(mat), as.matrix(mat2))
})
-
-test_that("stageObject works with DelayedMatrices (naive)", {
- dir <- tempfile()
- odir <- file.path(dir, experiment)
- dir.create(odir, recursive=TRUE)
-
- # Works in the pristine case, where it just extracts the seed.
- library(DelayedArray)
- mat <- as(matrix(rpois(10000, 1), ncol=10), "dgCMatrix")
- x <- DelayedArray(mat)
-
- info <- stageObject(x, dir, file.path(experiment, assay))
- expect_match(info$`$schema`, "sparse_matrix")
- expect_error(alabaster.base::.writeMetadata(info, dir), NA)
-
- mat2 <- loadArray(info, project=dir)
- expect_equal(unname(as.matrix(mat2)), unname(as.matrix(x)))
- expect_null(rownames(mat2))
- expect_null(colnames(mat2))
-
- # Works with assigned dimnames.
- y <- x
- dimnames(y) <- list(seq_len(nrow(y)), LETTERS[1:10])
-
- info <- stageObject(y, dir, file.path(experiment, "other"))
- expect_error(alabaster.base::.writeMetadata(info, dir), NA)
-
- mat2 <- loadArray(info, project=dir)
- expect_equal(as.matrix(mat2), as.matrix(y))
-})
|