diff --git a/DESCRIPTION b/DESCRIPTION index 28dec37e85..fa1bfcb3b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tiledb Type: Package -Version: 0.29.0.2 +Version: 0.29.0.3 Title: Modern Database Engine for Complex Data Based on Multi-Dimensional Arrays Authors@R: c(person("TileDB, Inc.", role = c("aut", "cph")), person("Dirk", "Eddelbuettel", email = "dirk@tiledb.com", role = "cre")) diff --git a/NEWS.md b/NEWS.md index f7d940cbdf..7f5263585b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ * Error messages displayed when a mismatched external pointer is detected now show both expected and encountered types (#740) -* `NDRectangle` types can now be instantiated for more domain data types (#741) +* `NDRectangle` types can now be instantiated for more domain data types (#741, #742) ## Documentation diff --git a/inst/tinytest/test_ndrectangle.R b/inst/tinytest/test_ndrectangle.R index 5a9a75c9cb..4bfe39eec5 100644 --- a/inst/tinytest/test_ndrectangle.R +++ b/inst/tinytest/test_ndrectangle.R @@ -6,22 +6,23 @@ ctx <- tiledb_ctx(limitTileDBCores()) if (tiledb_version(TRUE) < "2.25.0") exit_file("These tests needs TileDB 2.25.0 or later") -for (tp in c("INT32", "UINT32", "INT16", "UINT16", "INT64", "UINT64", "INT8", "UINT8")) { +for (tp in c("INT32", "UINT32", "INT16", "UINT16", "INT64", "UINT64", "INT8", "UINT8", "FLOAT32", "FLOAT64")) { if (grepl("INT64", tp)) { - expect_silent(intdim <- tiledb_dim("dim", bit64::as.integer64(c(1L, 100L)), - bit64::as.integer64(50L), type = tp)) + expect_silent(dim <- tiledb_dim("dim", bit64::as.integer64(c(1L, 100L)), bit64::as.integer64(50L), type = tp)) + } else if (grepl("FLOAT", tp)) { + expect_silent(dim <- tiledb_dim("dim", c(1, 100), 50, type = tp)) } else { - expect_silent(intdim <- tiledb_dim("dim", c(1L, 100L), 50L, type = tp)) + expect_silent(dim <- tiledb_dim("dim", c(1L, 100L), 50L, type = tp)) } - expect_true(is(intdim, "tiledb_dim")) - expect_silent(intdom <- tiledb_domain(dim = intdim)) - expect_true(is(intdom, "tiledb_domain")) + expect_true(is(dim, "tiledb_dim")) + expect_silent(dom <- tiledb_domain(dim = dim)) + expect_true(is(dom, "tiledb_domain")) - expect_error(ndr <- tiledb_ndrectangle(intdim)) - expect_silent(ndr <- tiledb_ndrectangle(intdom)) + expect_error(ndr <- tiledb_ndrectangle(dim)) + expect_silent(ndr <- tiledb_ndrectangle(dom)) expect_true(is(ndr, "tiledb_ndrectangle")) - expect_error(tiledb_ndrectangle_set_range(intdim, "dim", 1, 2)) # wrong type + expect_error(tiledb_ndrectangle_set_range(dim, "dim", 1, 2)) # wrong type expect_error(tiledb_ndrectangle_set_range(ndr, "notdim", 1, 2)) # wrong name expect_error(tiledb_ndrectangle_set_range(ndr, "dim", 1, 2L)) # wrong type expect_error(tiledb_ndrectangle_set_range(ndr, "dim", 1L, 2)) # wrong type @@ -29,11 +30,13 @@ for (tp in c("INT32", "UINT32", "INT16", "UINT16", "INT64", "UINT64", "INT8", "U expect_silent(ndr <- tiledb_ndrectangle_set_range(ndr, "dim", bit64::as.integer64(1L), bit64::as.integer64(20L))) + } else if (grepl("FLOAT", tp)) { + expect_silent(ndr <- tiledb_ndrectangle_set_range(ndr, "dim", 1, 20)) } else { expect_silent(ndr <- tiledb_ndrectangle_set_range(ndr, "dim", 1L, 20L)) } - expect_error(tiledb_ndrectangle_get_range(intdim, "dim")) # wrong type + expect_error(tiledb_ndrectangle_get_range(dim, "dim")) # wrong type expect_error(tiledb_ndrectangle_set_range(ndr, "notdim")) # wrong name if (grepl("INT64", tp)) { expect_equal(tiledb_ndrectangle_get_range(ndr, "dim"), bit64::as.integer64(c(1L, 20L))) diff --git a/src/libtiledb.cpp b/src/libtiledb.cpp index e283e00095..1de28cee63 100644 --- a/src/libtiledb.cpp +++ b/src/libtiledb.cpp @@ -5468,8 +5468,14 @@ XPtr libtiledb_ndrectangle_set_range(XPtr(Rcpp::as(end))); } else if (dtype == TILEDB_UINT8) { ndr->set_range(dimname, - static_cast(Rcpp::as(start)), - static_cast(Rcpp::as(end))); + static_cast(Rcpp::as(start)), + static_cast(Rcpp::as(end))); + } else if (dtype == TILEDB_FLOAT64) { + ndr->set_range(dimname, Rcpp::as(start), Rcpp::as(end)); + } else if (dtype == TILEDB_FLOAT32) { + ndr->set_range(dimname, + static_cast(Rcpp::as(start)), + static_cast(Rcpp::as(end))); } else { Rcpp::stop("Domain datatype '%s' of dimname '%s' is not currently supported", _tiledb_datatype_to_string(dtype), dimname); @@ -5517,6 +5523,13 @@ SEXP libtiledb_ndrectangle_get_range(XPtr ndr, auto range = ndr->range(dimname); return Rcpp::IntegerVector::create( static_cast(range[0]), static_cast(range[1]) ); + } else if (dtype == "FLOAT64") { + auto range = ndr->range(dimname); + return Rcpp::NumericVector::create(range[0], range[1]); + } else if (dtype == "FLOAT32") { + auto range = ndr->range(dimname); + return Rcpp::NumericVector::create( static_cast(range[0]), + static_cast(range[1])); } else { Rcpp::stop("Domain datatype '%s' of dimname '%s' is not currently supported", dtype, dimname); }