Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions R/TileDBArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions inst/tinytest/test_tiledbarray.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)