Skip to content

Cannot use the symbol i to subset an array #12

Description

@vtspaid

Hello again @pvanlaake , I appreciate the new updates to the package. The package seems to be in a pretty good place. I have noticed a couple small bugs that I can easily work around but I wanted to bring to your attention.

The first one is that using i as a symbol when trying to access data in an array produces unexpected results. i is always given the value of it's position. i.e. in x[i, ,] i is always treated as 1, and in in x[, i, ] i is always treated as 2. It's perhaps unusual to use i in this way but I found it out when trying to access elements within a for loop.

x <- array(1:100, c(5, 5, 4))
z <- as_zarr(x)
myarray <- z[["/"]]

i <- 4
myarray[i, i, i]
myarray[1, 2, 3]

# Works as expectd
for (j in 1:5) {
  print(myarray[j, 1:5, 1])
}

# Does not work as expected
for (i in 1:5) {
  print(myarray[i, 1:5, 1])
}

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