Skip to content

Commit

Permalink
Fix bug and add tests and anndataR fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
keller-mark committed May 7, 2024
1 parent 35b02ff commit fb8d744
Show file tree
Hide file tree
Showing 314 changed files with 2,354 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ data/
check/
vignettes/data/
*.Rproj
tests/testthat/test_data
tests/testthat/test_data
.ipynb_checkpoints/
*.ipynb
4 changes: 2 additions & 2 deletions R/zarr-array.R
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ ZarrArray <- R6::R6Class("ZarrArray",
private$load_metadata()
}
# Handle zero-dimensional arrays
if(is.null(private$shape)) {
if(is.null(private$shape) || length(private$shape) == 0) {
return(private$get_basic_selection_zd(selection, out = out, fields = fields))
}
return(private$get_basic_selection_nd(selection, out = out, fields = fields))
Expand All @@ -852,7 +852,7 @@ ZarrArray <- R6::R6Class("ZarrArray",
},
set_basic_selection = function(selection, value, fields = NA) {
# Handle zero-dimensional arrays
if(is.null(private$shape)) {
if(is.null(private$shape) || length(private$shape) == 0) {
return(private$set_basic_selection_zd(selection, value = value, fields = fields))
}
return(private$set_basic_selection_nd(selection, value = value, fields = fields))
Expand Down
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "anndata",
"encoding-version": "0.1.0"
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
8 changes: 8 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/X/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"encoding-type": "csr_matrix",
"encoding-version": "0.1.0",
"shape": [
50,
100
]
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/X/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
20 changes: 20 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/X/indices/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
4317
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i4",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
4317
],
"zarr_format": 2
}
Binary file added inst/extdata/fixtures/v2/example.zarr/X/indices/0
Binary file not shown.
20 changes: 20 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/X/indptr/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
51
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i4",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
51
],
"zarr_format": 2
}
Binary file added inst/extdata/fixtures/v2/example.zarr/X/indptr/0
Binary file not shown.
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "dict",
"encoding-version": "0.1.0"
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
8 changes: 8 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/counts/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"encoding-type": "csr_matrix",
"encoding-version": "0.1.0",
"shape": [
50,
100
]
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/counts/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
4317
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i4",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
4317
],
"zarr_format": 2
}
Binary file not shown.
20 changes: 20 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/counts/indptr/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
51
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i4",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
51
],
"zarr_format": 2
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"encoding-type": "csc_matrix",
"encoding-version": "0.1.0",
"shape": [
50,
100
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
4317
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i4",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
4317
],
"zarr_format": 2
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
101
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i4",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
101
],
"zarr_format": 2
}
Binary file not shown.
22 changes: 22 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/dense_X/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"chunks": [
50,
100
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<f4",
"fill_value": 0.0,
"filters": null,
"order": "C",
"shape": [
50,
100
],
"zarr_format": 2
}
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/dense_X/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "array",
"encoding-version": "0.2.0"
}
Binary file not shown.
22 changes: 22 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/layers/dense_counts/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"chunks": [
50,
100
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
50,
100
],
"zarr_format": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "array",
"encoding-version": "0.2.0"
}
Binary file not shown.
18 changes: 18 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"_index": "_index",
"column-order": [
"Float",
"FloatNA",
"Int",
"IntNA",
"Bool",
"BoolNA",
"n_genes_by_counts",
"log1p_n_genes_by_counts",
"total_counts",
"log1p_total_counts",
"leiden"
],
"encoding-type": "dataframe",
"encoding-version": "0.2.0"
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/Bool/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "nullable-boolean",
"encoding-version": "0.1.0"
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/Bool/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
20 changes: 20 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/Bool/mask/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
50
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "|b1",
"fill_value": false,
"filters": null,
"order": "C",
"shape": [
50
],
"zarr_format": 2
}
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/Bool/mask/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "array",
"encoding-version": "0.2.0"
}
Binary file not shown.
20 changes: 20 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/Bool/values/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chunks": [
50
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "|b1",
"fill_value": false,
"filters": null,
"order": "C",
"shape": [
50
],
"zarr_format": 2
}
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/Bool/values/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "array",
"encoding-version": "0.2.0"
}
Binary file not shown.
4 changes: 4 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/BoolNA/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"encoding-type": "nullable-boolean",
"encoding-version": "0.1.0"
}
3 changes: 3 additions & 0 deletions inst/extdata/fixtures/v2/example.zarr/obs/BoolNA/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
Loading

0 comments on commit fb8d744

Please sign in to comment.