Skip to content

Error in writing character arrays with arbitrary size #112

@Artur-man

Description

@Artur-man

Describe the bug

There seems to be an error when writing zarr arrays with character elements and arbitrary shape. I traced it here by debugging but couldn't really figure out:

pizzarr/R/zarr-array.R

Lines 633 to 648 in f84355d

chunk_setitem = function(chunk_coords, chunk_selection, value, fields = NA) {
# Reference: https://github.com/gzuidhof/zarr.js/blob/15e3a3f00eb19f0133018fb65f002311ea53bb7c/src/core/index.ts#L625
if (private$order == "C" && self$get_ndim() > 1) {
stop("Setting content for arrays in C-order is not yet supported.")
}
# Obtain key for chunk storage
chunk_key <- private$chunk_key(chunk_coords)
dtype_constr = private$dtype$get_typed_array_ctr()
chunk_size <- compute_size(private$chunks)
if (is_total_slice(chunk_selection, private$chunks)) {
# Totally replace chunk

To Reproduce

mat <- array(rep("text", 545*689), dim = c(545, 689))
zarr.array <- pizzarr::zarr_open(store = "data/string_test.zarr", mode = "w")
zarr.array$create_dataset(name = "assay", data = mat, shape = dim(mat), dtype = "<S20")

Error

Error in buf[offset_i_start:offset_i_stop] <- raw_vec_i : 
  replacement has length zero

Environment:

  • Release or git hash: f84355d
  • Operating system: macOS Monterey v12.5.1
  • R version: 4.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions