From dc6a10d885dd02e7ac8894e94925ab0369ca9cf1 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 5 Aug 2024 17:41:14 -0400 Subject: [PATCH 1/3] [r] Use `.Deprecated` for `used_shape` in R --- apis/r/R/TileDBArray.R | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/r/R/TileDBArray.R b/apis/r/R/TileDBArray.R index c81ab57870..dfc212e226 100644 --- a/apis/r/R/TileDBArray.R +++ b/apis/r/R/TileDBArray.R @@ -161,6 +161,7 @@ TileDBArray <- R6::R6Class( isTRUE(simplify) || isFALSE(simplify), isTRUE(index1) || isFALSE(index1) ) + .Deprecated(new="shape", msg="used_shape will be removed in TileDB-SOMA 1.14") dims <- self$dimnames() utilized <- vector(mode = 'list', length = length(dims)) names(utilized) <- dims From 0ff611e7517add07e03183ad34865af2b26263cc Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 5 Aug 2024 17:48:19 -0400 Subject: [PATCH 2/3] code-review feedback Co-authored-by: Dirk Eddelbuettel --- apis/r/R/TileDBArray.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/r/R/TileDBArray.R b/apis/r/R/TileDBArray.R index dfc212e226..e9bcea676c 100644 --- a/apis/r/R/TileDBArray.R +++ b/apis/r/R/TileDBArray.R @@ -161,7 +161,7 @@ TileDBArray <- R6::R6Class( isTRUE(simplify) || isFALSE(simplify), isTRUE(index1) || isFALSE(index1) ) - .Deprecated(new="shape", msg="used_shape will be removed in TileDB-SOMA 1.14") + .Deprecated(new="shape", msg="The 'used_shape' function will be removed in TileDB-SOMA 1.14.") dims <- self$dimnames() utilized <- vector(mode = 'list', length = length(dims)) names(utilized) <- dims From c52bdbf5c978044420ed80e184e8e748d031ea9a Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 5 Aug 2024 17:51:09 -0400 Subject: [PATCH 3/3] Suppress warnings in tests to prevent weird testthat output --- .../r/tests/testthat/test-SOMASparseNDArray.R | 41 +++++++++++++++---- .../r/tests/testthat/test-write-soma-resume.R | 5 ++- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/apis/r/tests/testthat/test-SOMASparseNDArray.R b/apis/r/tests/testthat/test-SOMASparseNDArray.R index 01f1929d91..90f307abee 100644 --- a/apis/r/tests/testthat/test-SOMASparseNDArray.R +++ b/apis/r/tests/testthat/test-SOMASparseNDArray.R @@ -416,7 +416,10 @@ test_that("SOMASparseNDArray bounding box", { } } - expect_type(bbox <- ndarray$used_shape(index1 = TRUE), 'list') + expect_type( + bbox <- suppressWarnings(ndarray$used_shape(index1 = TRUE), classes = "deprecatedWarning"), + 'list' + ) expect_length(bbox, length(dim(mat))) expect_equal(names(bbox), dnames) expect_true(all(vapply(bbox, length, integer(1L)) == 2L)) @@ -424,7 +427,10 @@ test_that("SOMASparseNDArray bounding box", { expect_equal(bbox[[i]], bit64::as.integer64(c(1L, dim(mat)[i]))) } - expect_type(bbox0 <- ndarray$used_shape(index1 = FALSE), 'list') + expect_type( + bbox0 <- suppressWarnings(ndarray$used_shape(index1 = FALSE), classes = "deprecatedWarning"), + 'list' + ) expect_length(bbox0, length(dim(mat))) expect_equal(names(bbox0), dnames) expect_true(all(vapply(bbox0, length, integer(1L)) == 2L)) @@ -432,7 +438,10 @@ test_that("SOMASparseNDArray bounding box", { expect_equal(bbox0[[i]], bit64::as.integer64(c(0L, dim(mat)[i] - 1L))) } - expect_s3_class(bboxS <- ndarray$used_shape(simplify = TRUE), 'integer64') + expect_s3_class( + bboxS <- suppressWarnings(ndarray$used_shape(simplify = TRUE), classes = "deprecatedWarning"), + 'integer64' + ) expect_length(bboxS, length(dim(mat))) expect_equal(names(bboxS), dnames) for (i in seq_along(bboxS)) { @@ -459,7 +468,7 @@ test_that("SOMASparseNDArray without bounding box", { expect_false(all(bbox_names %in% names(tiledb::tiledb_get_all_metadata(ndarray$object)))) - expect_error(ndarray$used_shape()) + expect_error(suppressWarnings(ndarray$used_shape(), classes = "deprecatedWarning")) }) test_that("SOMASparseNDArray with failed bounding box", { @@ -489,7 +498,7 @@ test_that("SOMASparseNDArray with failed bounding box", { expect_false(all(bbox_names %in% names(tiledb::tiledb_get_all_metadata(ndarray$object)))) - expect_error(ndarray$used_shape()) + expect_error(suppressWarnings(ndarray$used_shape(), classes = "deprecatedWarning")) }) test_that("SOMASparseNDArray bounding box implicitly-stored values", { @@ -521,7 +530,10 @@ test_that("SOMASparseNDArray bounding box implicitly-stored values", { } } - expect_type(bbox <- ndarray$used_shape(index1 = TRUE), 'list') + expect_type( + bbox <- suppressWarnings(ndarray$used_shape(index1 = TRUE), classes = "deprecatedWarning"), + 'list' + ) expect_length(bbox, length(dim(mat))) expect_equal(names(bbox), dnames) expect_true(all(vapply(bbox, length, integer(1L)) == 2L)) @@ -529,7 +541,10 @@ test_that("SOMASparseNDArray bounding box implicitly-stored values", { expect_equal(bbox[[i]], bit64::as.integer64(c(1L, dim(mat)[i]))) } - expect_type(bbox0 <- ndarray$used_shape(index1 = FALSE), 'list') + expect_type( + bbox0 <- suppressWarnings(ndarray$used_shape(index1 = FALSE), classes = "deprecatedWarning"), + 'list' + ) expect_length(bbox0, length(dim(mat))) expect_equal(names(bbox0), dnames) expect_true(all(vapply(bbox0, length, integer(1L)) == 2L)) @@ -537,7 +552,10 @@ test_that("SOMASparseNDArray bounding box implicitly-stored values", { expect_equal(bbox0[[i]], bit64::as.integer64(c(0L, dim(mat)[i] - 1L))) } - expect_s3_class(bboxS <- ndarray$used_shape(simplify = TRUE), 'integer64') + expect_s3_class( + bboxS <- suppressWarnings(ndarray$used_shape(simplify = TRUE), classes = "deprecatedWarning"), + 'integer64' + ) expect_length(bboxS, length(dim(mat))) expect_equal(names(bboxS), dnames) for (i in seq_along(bboxS)) { @@ -551,7 +569,12 @@ test_that("SOMASparseNDArray bounding box implicitly-stored values", { ranges[i] <- bit64::as.integer64(max(range(slot(mat, s)))) } expect_equal(ndarray$non_empty_domain(), ranges) - expect_true(all(ndarray$non_empty_domain() < ndarray$used_shape(simplify = TRUE))) + expect_true(all( + ndarray$non_empty_domain() < suppressWarnings( + ndarray$used_shape(simplify = TRUE), + classes = "deprecatedWarning" + ) + )) }) test_that("Bounding box assertions", { diff --git a/apis/r/tests/testthat/test-write-soma-resume.R b/apis/r/tests/testthat/test-write-soma-resume.R index c73b75a5ae..5891f2b6ea 100644 --- a/apis/r/tests/testthat/test-write-soma-resume.R +++ b/apis/r/tests/testthat/test-write-soma-resume.R @@ -286,7 +286,10 @@ test_that("Resume-mode sparse arrays", { expected.label = "knex" ) bbox <- tryCatch( - as.integer(ssac$used_shape(simplify = TRUE, index1 = TRUE)), + as.integer(suppressWarnings( + ssac$used_shape(simplify = TRUE, index1 = TRUE), + classes = "deprecatedWarning" + )), error = function(...) NULL ) if (!is.null(bbox)) {