From 2274bbc3e510fcb448e2cb813cabfa27b7722c21 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 16 May 2021 10:09:50 -0500 Subject: [PATCH 1/3] correct attr type assignment for one-col attr selection with row+col --- R/TileDBArray.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/TileDBArray.R b/R/TileDBArray.R index b67b0e6eee..e8e846ac63 100644 --- a/R/TileDBArray.R +++ b/R/TileDBArray.R @@ -773,6 +773,8 @@ setMethod("[<-", "tiledb_array", value <- data.frame(x=as.matrix(value)[seq(1, d[1]*d[2])]) colnames(value) <- attrnames allnames <- attrnames + alltypes <- attrtypes + allnullable <- attrnullable } ## Case 4: dense, list on RHS e.g. the ex_1.R example From 1bf15baee5028dc61ffba2c9d6de4163be9860a1 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 16 May 2021 12:07:12 -0500 Subject: [PATCH 2/3] additional tests for #245 and #246 --- inst/tinytest/test_tiledbarray.R | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/inst/tinytest/test_tiledbarray.R b/inst/tinytest/test_tiledbarray.R index ef873dcfca..8f255f2d7b 100644 --- a/inst/tinytest/test_tiledbarray.R +++ b/inst/tinytest/test_tiledbarray.R @@ -1076,3 +1076,44 @@ expect_true(is.list(res)) expect_equal(length(res), 2L) expect_equal(res$vals, mat) expect_equal(res$vals2, 10*mat) + +## PR #245 (variant of examples/ex_1.R) +uri <- tempfile() +dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 10L), 10L, "INT32"), + tiledb_dim("cols", c(1L, 5L), 5L, "INT32"))) +schema <- tiledb_array_schema(dom, + attrs = c(tiledb_attr("a", type = "INT32"), + tiledb_attr("b", type = "FLOAT64"), + tiledb_attr("c", type = "CHAR", ncells=NA_integer_)), + cell_order = "ROW_MAJOR", tile_order = "ROW_MAJOR") +tiledb_array_create(uri, schema) +data <- list(a=array(seq(1:50), dim = c(10,5)), + b=array(as.double(seq(101,by=0.5,length=50)), dim = c(10,5)), + c=array(c(letters[1:26], "brown", "fox", LETTERS[1:22]), dim = c(10,5))) +A <- tiledb_array(uri) +A[] <- data +obj <- tiledb_array(uri, attrs="a", as.data.frame=TRUE) +res <- obj[] +expect_equal(colnames(res), c("rows", "cols", "a")) # this was the PR issues +obj <- tiledb_array(uri, attrs="a", as.matrix=TRUE) # this is the preferred accessor here +expect_equal(obj[], data[["a"]]) +obj <- tiledb_array(uri, as.matrix=TRUE) # test all three matrices +res <- obj[] +expect_equal(res[["a"]], data[["a"]]) +expect_equal(res[["b"]], data[["b"]]) +expect_equal(res[["c"]], data[["c"]]) + +## PR #246 +N <- 25L +K <- 4L +uri <- tempfile() +schema <- tiledb_array_schema(tiledb_domain(dims=c(tiledb_dim("d1", c(1L, N), tile=N, type="INT32"), + tiledb_dim("d2", c(1L, K), tile=K, type="INT32"))), + sparse=FALSE, + attrs=tiledb_attr("x", type="FLOAT64")) +tiledb_array_create(uri, schema) +obj <- tiledb_array(uri, attrs="x", query_type="WRITE") +M <- matrix(runif(N*K), N, K) +obj[] <- M # prior to #246 this write had a write data type +chk <- tiledb_array(uri, as.matrix=TRUE) +expect_equal(chk[], M) From afc5a82f3272562d65ef8054c9ddc9f3731faf33 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 16 May 2021 13:18:03 -0500 Subject: [PATCH 3/3] update NEWS for #245 and #246 --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index cef2e35fc3..8c4a5b13f4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,10 @@ * Unit tests of character columns in data frames accomodate R versions prior to R 4.0.0 in all cases (#243) +* Dimension reduction for attribute-selected columns was incorrect in some cases (#245) + +* Attribute-selected columns were using dimenion data types in some cases (#246) + # tiledb 0.9.1