Skip to content

Commit

Permalink
tests: add peaks variables unit tests for MsBackendDataFrame
Browse files Browse the repository at this point in the history
- Add support for peaks variables to `MsBackendDataFrame` and add/test its
  funcitionality (issue #289).
  • Loading branch information
jorainer committed Jun 5, 2023
1 parent db17225 commit a6fabdf
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions tests/testthat/test_Spectra.R
Original file line number Diff line number Diff line change
Expand Up @@ -1715,13 +1715,20 @@ with_parameters_test_that("peaks variables and filtering properly works", {
## check applyProcessing
res <- applyProcessing(sf)
expect_equal(res$rtime, sf$rtime)
expect_equal(res$mz, sf$mz)
expect_equal(res@backend$mz, sf$mz)
expect_equal(res$intensity, sf$intensity)
expect_equal(res@backend$intensity, sf$intensity)
a <- NumericList(lapply(res$mz, unname), compress = FALSE)
b <- NumericList(lapply(sf$mz, unname), compress = FALSE)
expect_equal(a, b)
a <- NumericList(lapply(res@backend$mz, unname), compress = FALSE)
expect_equal(a, b)
a <- NumericList(lapply(res$intensity, unname), compress = FALSE)
b <- NumericList(lapply(sf$intensity, unname), compress = FALSE)
expect_equal(a, b)
a <- NumericList(lapply(res@backend$intensity, unname), compress = FALSE)
expect_equal(a, b)
expect_equal(res$pk_ann, sf$pk_ann)
expect_equal(res@backend$pk_ann, sf$pk_ann)
expect_true(is.matrix(res@backend@peaksData[[1L]]))
if (inherits(bcknd, "MsBackendMemory"))
expect_true(is.matrix(res@backend@peaksData[[1L]]))
expect_equal(
res$pk_ann, list(c(NA_character_), c("A", "B"), c("D", "E", "F")))

Expand All @@ -1734,8 +1741,12 @@ with_parameters_test_that("peaks variables and filtering properly works", {
spd <- spectraData(sf) # without peaks variables
spectraData(res) <- spd
expect_equal(rtime(res), rtime(sf))
expect_equal(res$mz, sf$mz)
expect_equal(res$intensity, sf$intensity)
a <- NumericList(lapply(res$mz, unname), compress = FALSE)
b <- NumericList(lapply(sf$mz, unname), compress = FALSE)
expect_equal(a, b)
a <- NumericList(lapply(res$intensity, unname), compress = FALSE)
b <- NumericList(lapply(sf$intensity, unname), compress = FALSE)
expect_equal(a, b)
expect_equal(res$pk_ann, sf$pk_ann)
expect_true(length(res@processingQueue) == 0)

Expand All @@ -1746,5 +1757,6 @@ with_parameters_test_that("peaks variables and filtering properly works", {
expect_error(res$pk_ann <- list(c(NA_character_), c("A", "D"),
c("E", "F", "G")), "non-empty processing")
}, cases(
MsBackendMemory = list(bcknd = MsBackendMemory())
MsBackendMemory = list(bcknd = MsBackendMemory()),
MsBackendDataFrame = list(bcknd = MsBackendDataFrame())
))

0 comments on commit a6fabdf

Please sign in to comment.