diff --git a/R/HDF5AnnData.R b/R/HDF5AnnData.R index 89d4734d..b34bde7b 100644 --- a/R/HDF5AnnData.R +++ b/R/HDF5AnnData.R @@ -15,10 +15,10 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint #' @field X The X slot X = function(value) { if (missing(value)) { - # trackstatus: class=HDF5AnnData, feature=get_X, status=wip + # trackstatus: class=HDF5AnnData, feature=get_X, status=done read_h5ad_element(private$.h5obj, "/X") } else { - # trackstatus: class=HDF5AnnData, feature=set_X, status=wip + # trackstatus: class=HDF5AnnData, feature=set_X, status=done value <- private$.validate_matrix(value, "X") write_h5ad_element(value, private$.h5obj, "/X") } @@ -28,10 +28,10 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint #' `obs` and `var`. layers = function(value) { if (missing(value)) { - # trackstatus: class=HDF5AnnData, feature=get_layers, status=wip + # trackstatus: class=HDF5AnnData, feature=get_layers, status=done read_h5ad_element(private$.h5obj, "layers") } else { - # trackstatus: class=HDF5AnnData, feature=set_layers, status=wip + # trackstatus: class=HDF5AnnData, feature=set_layers, status=done value <- private$.validate_layers(value) write_h5ad_element(value, private$.h5obj, "/layers") } @@ -39,10 +39,10 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint #' @field obs The obs slot obs = function(value) { if (missing(value)) { - # trackstatus: class=HDF5AnnData, feature=get_obs, status=wip + # trackstatus: class=HDF5AnnData, feature=get_obs, status=done read_h5ad_element(private$.h5obj, "/obs", include_index = FALSE) } else { - # trackstatus: class=HDF5AnnData, feature=set_obs, status=wip + # trackstatus: class=HDF5AnnData, feature=set_obs, status=done value <- private$.validate_obsvar_dataframe(value, "obs") write_h5ad_element( value, @@ -55,10 +55,10 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint #' @field var The var slot var = function(value) { if (missing(value)) { - # trackstatus: class=HDF5AnnData, feature=get_var, status=wip + # trackstatus: class=HDF5AnnData, feature=get_var, status=done read_h5ad_element(private$.h5obj, "/var", include_index = FALSE) } else { - # trackstatus: class=HDF5AnnData, feature=set_var, status=wip + # trackstatus: class=HDF5AnnData, feature=set_var, status=done value <- private$.validate_obsvar_dataframe(value, "var") write_h5ad_element( value, @@ -70,9 +70,8 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint }, #' @field obs_names Names of observations obs_names = function(value) { - # TODO: directly write to and read from /obs/_index if (missing(value)) { - # trackstatus: class=HDF5AnnData, feature=get_obs_names, status=wip + # trackstatus: class=HDF5AnnData, feature=get_obs_names, status=done # obs names are cached to avoid reading all of obs whenever they are # accessed if (is.null(private$.obs_names)) { @@ -80,7 +79,7 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint } private$.obs_names } else { - # trackstatus: class=HDF5AnnData, feature=set_obs_names, status=wip + # trackstatus: class=HDF5AnnData, feature=set_obs_names, status=done value <- private$.validate_obsvar_names(value, "obs") write_h5ad_data_frame_index(value, private$.h5obj, "obs", "_index") private$.obs_names <- value @@ -90,7 +89,7 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint var_names = function(value) { # TODO: directly write to and read from /var/_index if (missing(value)) { - # trackstatus: class=HDF5AnnData, feature=get_var_names, status=wip + # trackstatus: class=HDF5AnnData, feature=get_var_names, status=done # var names are cached to avoid reading all of var whenever they are # accessed if (is.null(private$.var_names)) { @@ -98,7 +97,7 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint } private$.var_names } else { - # trackstatus: class=HDF5AnnData, feature=set_var_names, status=wip + # trackstatus: class=HDF5AnnData, feature=set_var_names, status=done value <- private$.validate_obsvar_names(value, "var") write_h5ad_data_frame_index(value, private$.h5obj, "var", "_index") private$.var_names <- value diff --git a/tests/testthat/test-HDF5AnnData.R b/tests/testthat/test-HDF5AnnData.R index 1fadfc58..240dd2f6 100644 --- a/tests/testthat/test-HDF5AnnData.R +++ b/tests/testthat/test-HDF5AnnData.R @@ -10,14 +10,14 @@ test_that("opening H5AD works", { adata <- HDF5AnnData$new(file) # GETTERS ---------------------------------------------------------------- -# trackstatus: class=HDF5AnnData, feature=test_get_X, status=wip +# trackstatus: class=HDF5AnnData, feature=test_get_X, status=done test_that("reading X works", { X <- adata$X expect_s4_class(X, "dgRMatrix") expect_equal(dim(X), c(50, 100)) }) -# trackstatus: class=HDF5AnnData, feature=test_get_layers, status=wip +# trackstatus: class=HDF5AnnData, feature=test_get_layers, status=done test_that("reading layers works", { layers <- adata$layers expect_true(is.list(layers), "list") @@ -27,7 +27,7 @@ test_that("reading layers works", { ) }) -# trackstatus: class=HDF5AnnData, feature=test_get_obs, status=wip +# trackstatus: class=HDF5AnnData, feature=test_get_obs, status=done test_that("reading obs works", { obs <- adata$obs expect_s3_class(obs, "data.frame") @@ -40,7 +40,7 @@ test_that("reading obs works", { ) }) -# trackstatus: class=HDF5AnnData, feature=test_get_var, status=wip +# trackstatus: class=HDF5AnnData, feature=test_get_var, status=done test_that("reading var works", { var <- adata$var expect_s3_class(var, "data.frame") @@ -54,13 +54,13 @@ test_that("reading var works", { ) }) -# trackstatus: class=HDF5AnnData, feature=test_get_obs_names, status=wip +# trackstatus: class=HDF5AnnData, feature=test_get_obs_names, status=done test_that("reading obs names works", { obs_names <- adata$obs_names expect_vector(obs_names, ptype = character(), size = 50) }) -# trackstatus: class=HDF5AnnData, feature=test_get_var_names, status=wip +# trackstatus: class=HDF5AnnData, feature=test_get_var_names, status=done test_that("reading var names works", { var_names <- adata$var_names expect_vector(var_names, ptype = character(), size = 100) @@ -72,7 +72,7 @@ test_that("creating empty H5AD works", { expect_silent(HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20)) }) -# trackstatus: class=HDF5AnnData, feature=test_set_X, status=wip +# trackstatus: class=HDF5AnnData, feature=test_set_X, status=done test_that("writing X works", { h5ad_file <- withr::local_tempfile(fileext = ".h5ad") h5ad <- HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20) @@ -81,7 +81,7 @@ test_that("writing X works", { expect_silent(h5ad$X <- X) }) -# trackstatus: class=HDF5AnnData, feature=test_set_layers, status=wip +# trackstatus: class=HDF5AnnData, feature=test_set_layers, status=done test_that("writing layers works", { h5ad_file <- withr::local_tempfile(fileext = ".h5ad") h5ad <- HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20) @@ -90,7 +90,7 @@ test_that("writing layers works", { expect_silent(h5ad$layers <- list(layer1 = X, layer2 = X)) }) -# trackstatus: class=HDF5AnnData, feature=test_set_obs, status=wip +# trackstatus: class=HDF5AnnData, feature=test_set_obs, status=done test_that("writing obs works", { h5ad_file <- withr::local_tempfile(fileext = ".h5ad") h5ad <- HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20) @@ -104,7 +104,7 @@ test_that("writing obs works", { expect_identical(h5ad$obs_names, 1:10) }) -# trackstatus: class=HDF5AnnData, feature=test_set_var, status=wip +# trackstatus: class=HDF5AnnData, feature=test_set_var, status=done test_that("writing var works", { h5ad_file <- withr::local_tempfile(fileext = ".h5ad") h5ad <- HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20) @@ -118,7 +118,7 @@ test_that("writing var works", { expect_identical(h5ad$var_names, 1:20) }) -# trackstatus: class=HDF5AnnData, feature=test_set_obs_names, status=wip +# trackstatus: class=HDF5AnnData, feature=test_set_obs_names, status=done test_that("writing obs names works", { h5ad_file <- withr::local_tempfile(fileext = ".h5ad") h5ad <- HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20) @@ -127,7 +127,7 @@ test_that("writing obs names works", { expect_identical(h5ad$obs_names, LETTERS[1:10]) }) -# trackstatus: class=HDF5AnnData, feature=test_set_var_names, status=wip +# trackstatus: class=HDF5AnnData, feature=test_set_var_names, status=done test_that("writing var names works", { h5ad_file <- withr::local_tempfile(fileext = ".h5ad") h5ad <- HDF5AnnData$new(h5ad_file, obs_names = 1:10, var_names = 1:20)