Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Jun 1, 2024
1 parent 1681e6f commit 4bd118a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/testthat/setup-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,23 @@ setup({
teardown({

})

zarr_volcano <- function() {
dir <- file.path(tempdir(TRUE), "volcano.zarr")

unlink(dir, recursive = TRUE, force = TRUE)

z <- DirectoryStore$new(dir)

a <- volcano

za <- zarr_create(dim(volcano), path = "volcano", store = z, overwrite = TRUE)

za$set_item("...", a)

g <- zarr_open_group(z)

g$get_attrs()$set_item("tile", "volcano")

g
}
11 changes: 11 additions & 0 deletions tests/testthat/test-s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ test_that("S3 methods of Zarr object", {
#Converting Zarr to array
expect_equal(as.array(z), a)
})

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)
})

0 comments on commit 4bd118a

Please sign in to comment.