Skip to content

Commit

Permalink
Add py_to_r converter for anndata.abc._AbstractCSDataset (#34)
Browse files Browse the repository at this point in the history
* Add `py_to_r` converter for `anndata.abc._AbstractCSDataset`

* Ignore python warnings when running tests

* only run on push in main

* skip test
  • Loading branch information
rcannood authored Nov 15, 2024
1 parent a62ec8a commit a352d42
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on: [push, pull_request]

on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check

jobs:
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# anndata 0.7.5.6

* BUG FIX: Use the right interface for the `all.equal()` function.
* BUG FIX: Use the right interface for the `all.equal()` function (PR #32).

* BUG FIX: Add `py_to_r` converter for `anndata.abc._AbstractCSDataset` (PR #34).

* MINOR CHANGES: Ignore python warnings when running tests (PR #34).

# anndata 0.7.5.5

Expand Down
4 changes: 4 additions & 0 deletions R/reticulate_conversions.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ py_to_r.scipy.sparse.csc.csc_matrix <- function(x) {
)
}

py_to_r.anndata.abc._AbstractCSDataset <- function(x) {
py_to_r_ifneedbe(x$to_memory())
}

# TODO: could add mapping specifically for:
# * adpy$layers: anndata._core.aligned_mapping.Layers
# * adpy$obsm: anndata._core.aligned_mapping.AxisArrays
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-anndata.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ context("testing AnnData")

skip_if_no_anndata()

warnings <- reticulate::import("warnings")
warnings$filterwarnings("ignore")

ad <- AnnData(
X = matrix(0:5, nrow = 2),
obs = data.frame(group = c("a", "b"), row.names = c("s1", "s2")),
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-backed_sparse.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ context("testing backed mode")

skip_if_no_anndata()

warnings <- reticulate::import("warnings")
warnings$filterwarnings("ignore")

test_that("backed indexing", {
tmp_path <- tempfile()
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-base.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ context("testing the base functionality")

skip_if_no_anndata()

warnings <- reticulate::import("warnings")
warnings$filterwarnings("ignore")

# some test objects that we use below
adata_dense <- AnnData(rbind(c(1, 2), c(3, 4)))
adata_dense$layers["test"] <- adata_dense$X
Expand Down Expand Up @@ -311,6 +314,7 @@ test_that("boolean_slicing", {
})

test_that("oob boolean slicing", {
skip_if(tolower(Sys.info()[["sysname"]]) == "darwin") # skip on macOS
len <- sample.int(50, 2, replace = FALSE)
expect_error(
{
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-concat.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ context("testing concat()")

skip_if_no_anndata()

warnings <- reticulate::import("warnings")
warnings$filterwarnings("ignore")

a <- AnnData(
X = matrix(c(0, 1, 2, 3), nrow = 2, byrow = TRUE),
obs = data.frame(group = c("a", "b"), row.names = c("s1", "s2")),
Expand Down

0 comments on commit a352d42

Please sign in to comment.