keller-mark / pizzarr

Slice into Zarr arrays in R 🍕
https://keller-mark.github.io/pizzarr/
MIT License
25 stars 2 forks source link

Add tests with ":" indexing #40

Closed keller-mark closed 2 weeks ago

dblodgett-usgs commented 1 month ago

I just implemented a test that I think addresses this -- but I'm not sure I know exactly what you mean by ":" indexing.

Is this what you are getting at?

test_that("Zarr Array can be accessed with ", {
  g <- zarr_volcano()

  a <- g$get_item("volcano")

  sub <- a[1:10,1]

  expect_equal(class(sub), c("NestedArray", "R6"))
  expect_equal(dim(sub$as.array()), 10, 1)
})
keller-mark commented 1 month ago

I had meant using the string literal ":" in the selection list to achieve the equivalent behavior of Numpy like

a = np.zeros((4,5,6))
b = a[1:2,:,0:3]

Where the middle : without a start or end selects all 5 items along the middle axis.

This would be in contrast to the behavior of the string "..." which we use to select along all of the remaining array dimensions.

dblodgett-usgs commented 1 month ago

I see -- I knew I was missing something. My Python isn't super strong. I'm working through a few things related to this and will see if I can write up some testing.

keller-mark commented 2 weeks ago

Fixed in https://github.com/keller-mark/pizzarr/pull/85