r-lib / rray

Simple Arrays
https://rray.r-lib.org
GNU General Public License v3.0
130 stars 12 forks source link

subset behavior #251

Closed lei0zhou closed 4 years ago

lei0zhou commented 4 years ago
library(rray)

n <- 500
n_dim <- rray(rep(n/2^12, 2^12))
dim(n_dim) <- rep(2, 12)

> dim(n_dim[pad(),1,])
 [1] 2 2 2 2 2 2 2 2 2 2 2 1
> dim(n_dim[pad(),1])
 [1] 2 2 2 2 2 2 2 2 2 2 2 1
> dim(n_dim[pad(),1,,])
 [1] 2 2 2 2 2 2 2 2 2 2 1 2

is this a bug? in that it need double commas to subset on the second to last dimension

DavisVaughan commented 4 years ago

Yea, this is definitely not right. I don't think I quite understood how subsetting should work until now. This is what the result should be.

library(rray)

n <- 500
n_dim <- rray(rep(n/2^12, 2^12))
dim(n_dim) <- rep(2, 12)

dim(n_dim[pad(),1,])
#>  [1] 2 2 2 2 2 2 2 2 2 2 1 2
dim(n_dim[pad(),1])
#>  [1] 2 2 2 2 2 2 2 2 2 2 2 1
dim(n_dim[pad(),1,,])
#>  [1] 2 2 2 2 2 2 2 2 2 1 2 2

Created on 2019-11-26 by the reprex package (v0.3.0.9000)

Closing this in favor of #252 which tracks the exact problem.