Skip to content

read_zarr_array sorts permuted full indices from index #241

Description

@Artur-man

I came across with a strange behaviour of read_zarr_array.

> mat <- array(1:25, dim = c(5,5))
> mat
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    6   11   16   21
[2,]    2    7   12   17   22
[3,]    3    8   13   18   23
[4,]    4    9   14   19   24
[5,]    5   10   15   20   25
> mat_zarr <- as(mat, "ZarrArray")
> set.seed(1)
> index <- list(sample(1:5,5), NULL)
> index
[[1]]
[1] 1 4 3 5 2

[[2]]
NULL

> Rarr::read_zarr_array(mat_zarr@seed@zarr_path, index)
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    6   11   16   21
[2,]    2    7   12   17   22
[3,]    3    8   13   18   23
[4,]    4    9   14   19   24
[5,]    5   10   15   20   25

This does not happen if indices are a subset, but not a permutation of the full index set.

> mat <- array(1:25, dim = c(5,5))
> mat
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    6   11   16   21
[2,]    2    7   12   17   22
[3,]    3    8   13   18   23
[4,]    4    9   14   19   24
[5,]    5   10   15   20   25
> mat_zarr <- as(mat, "ZarrArray")
> set.seed(1)
> index <- list(sample(1:5,3), NULL)
> index
[[1]]
[1] 1 4 3

[[2]]
NULL

> Rarr::read_zarr_array(mat_zarr@seed@zarr_path, index)
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    6   11   16   21
[2,]    4    9   14   19   24
[3,]    3    8   13   18   23

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions