From d1cc7ae07cfd016b826af6697f8ec8204101ea74 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 13 Feb 2023 17:46:59 -0500 Subject: [PATCH 1/3] Safer check for NAs in `tiledb_config()` Replace `if(is.na())` as R 4.2 errors when conditions > 1L Instead, removes NAs from `config` Then, checks the length of `config`; if there is a length, adds it to the TileDB config fixes #518 --- R/Config.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/Config.R b/R/Config.R index 6f6a819ba8..407dd798b3 100644 --- a/R/Config.R +++ b/R/Config.R @@ -55,7 +55,8 @@ tiledb_config.from_ptr <- function(ptr) { #' @importFrom methods new #' @export tiledb_config tiledb_config <- function(config = NA_character_) { - if (!is.na(config)) { + config <- config[!is.na(x = config)] + if (length(x = config)) { stopifnot(`If given, the 'config' argument must be a name, value character vector` = is.character(config) && !is.null(names(config))) ptr <- libtiledb_config(config) } else { From 9bb3a67147d80ffdbc98f3181af19ae35d7c3293 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 13 Feb 2023 17:57:31 -0500 Subject: [PATCH 2/3] Update tests for input vectors and NAs --- inst/tinytest/test_config.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/inst/tinytest/test_config.R b/inst/tinytest/test_config.R index b9ca3a133e..5f816df25e 100644 --- a/inst/tinytest/test_config.R +++ b/inst/tinytest/test_config.R @@ -20,6 +20,15 @@ expect_error(tiledb_config(1)) expect_error(tiledb_config(c(foo = 1))) #}) +## handle cases with NAs +expect_silent(cfg <- tiledb_config(c(a = "1"))) +expect_equal(cfg["a"], c(a = "1")) +expect_silent(cfg <- tiledb_config(c(a = "1", b = "2"))) +expect_equal(cfg["b"], c(b = "2")) +expect_equal(head(names(as.vector(cfg)), 2L), c("a", "b")) +expect_silent(cfg <- tiledb_config(c(a = "1", c = NA_character_, b = "2"))) +expect_equal(head(names(as.vector(cfg)), 2L), c("a", "b")) + #test_that("tiledb_config indexing works", { cfg <- tiledb_config() cfg["foo"] <- "bar" From 8f820bbd7c65ab041c9d074e66fd429877192c3c Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 13 Feb 2023 20:50:17 -0500 Subject: [PATCH 3/3] Update changelog [ci_skip] --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 519b3c1694..30b6f77485 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # tiledb 0.18.0.2 (Development) * This release of the R package builds against [TileDB 2.14.1](/~https://github.com/TileDB-Inc/TileDB/releases/tag/2.14.1), and has also been tested against earlier releases as well as the development version (#502). +* Safer checking of `NAs` in `tiledb_config()` to support R 4.2 conditional lengths (#518, #519) ## Improvements