Skip to content

Commit 47b0bd4

Browse files
committed
Avoid warnings in test-from_Seurat
1 parent c28b763 commit 47b0bd4

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/testthat/test-from_Seurat.R

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
skip_if_not_installed("Seurat")
22
library(Seurat)
33

4+
`%||%` <- rlang::`%||%`
5+
46
known_issues <- read_known_issues()
57

68
counts <- matrix(rbinom(20000, 1000, .001), nrow = 100)
@@ -197,8 +199,16 @@ test_that("as_AnnData (Seurat) works with list mappings", {
197199
obsm_mapping = as.list(.from_Seurat_guess_obsms(obj, active_assay)),
198200
varm_mapping = as.list(.from_Seurat_guess_varms(obj, active_assay)),
199201
obsp_mapping = as.list(.from_Seurat_guess_obsps(obj, active_assay)),
200-
varp_mapping = as.list(.from_Seurat_guess_varps(obj)),
201-
uns_mapping = as.list(.from_Seurat_guess_uns(obj))
202+
varp_mapping = if (length(as.list(.from_Seurat_guess_varps(obj))) > 0) {
203+
as.list(.from_Seurat_guess_varps(obj))
204+
} else {
205+
FALSE
206+
},
207+
uns_mapping = if (length(as.list(.from_Seurat_guess_uns(obj))) > 0) {
208+
as.list(.from_Seurat_guess_uns(obj))
209+
} else {
210+
FALSE
211+
}
202212
)
203213
)
204214
})
@@ -214,8 +224,8 @@ test_that("as_AnnData (Seurat) works with unnamed mappings", {
214224
obsm_mapping = unname(.from_Seurat_guess_obsms(obj, active_assay)),
215225
varm_mapping = unname(.from_Seurat_guess_varms(obj, active_assay)),
216226
obsp_mapping = unname(.from_Seurat_guess_obsps(obj, active_assay)),
217-
varp_mapping = unname(.from_Seurat_guess_varps(obj)),
218-
uns_mapping = unname(.from_Seurat_guess_uns(obj))
227+
varp_mapping = unname(.from_Seurat_guess_varps(obj)) %||% FALSE,
228+
uns_mapping = unname(.from_Seurat_guess_uns(obj)) %||% FALSE
219229
)
220230
)
221231
})

0 commit comments

Comments
 (0)