Skip to content

Commit

Permalink
fix: use zarr-python 2.18.4 for Zarr V2 string compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Feb 7, 2025
1 parent 4464d2a commit b100b29
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 37 deletions.
40 changes: 40 additions & 0 deletions zarrs/tests/data/v2_str0_zarr_python_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "zarr==2.18.4",
# ]
# ///

import zarr

path_out = "tests/data/zarr_python_compat/str_v2_fv_0.zarr"
array = zarr.open(
path_out,
dtype=str,
shape=(5,),
chunks=(2,),
mode='w',
)
array[0] = "a"
array[1] = "bb"
array[2] = ""
print(array.info)
print(array[:])
assert (array[:] == ["a", "bb", "", "0", "0"]).all()

path_out = "tests/data/zarr_python_compat/str_v2_fv_null.zarr"
array = zarr.open(
path_out,
dtype=str,
shape=(5,),
chunks=(2,),
fill_value = None,
mode='w',
)
array[0] = "a"
array[1] = "bb"
array[2] = ""
print(array.info)
print(array[:])
assert (array[:] == ["a", "bb", "", "", None]).all() # Yikes
File renamed without changes.
39 changes: 22 additions & 17 deletions zarrs/tests/data/zarr_python_compat/str_v2_fv_0.zarr/.zarray
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"shape": [
5
],
"chunks": [
2
],
"fill_value": 0,
"order": "C",
"filters": [
{
"id": "vlen-utf8"
}
],
"dimension_separator": ".",
"compressor": null,
"zarr_format": 2,
"dtype": "|O"
"chunks": [
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "|O",
"fill_value": "0",
"filters": [
{
"id": "vlen-utf8"
}
],
"order": "C",
"shape": [
5
],
"zarr_format": 2
}

This file was deleted.

Binary file modified zarrs/tests/data/zarr_python_compat/str_v2_fv_0.zarr/0
Binary file not shown.
Binary file modified zarrs/tests/data/zarr_python_compat/str_v2_fv_0.zarr/1
Binary file not shown.
39 changes: 22 additions & 17 deletions zarrs/tests/data/zarr_python_compat/str_v2_fv_null.zarr/.zarray
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"shape": [
5
],
"chunks": [
2
],
"fill_value": null,
"order": "C",
"filters": [
{
"id": "vlen-utf8"
}
],
"dimension_separator": ".",
"compressor": null,
"zarr_format": 2,
"dtype": "|O"
"chunks": [
2
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "|O",
"fill_value": null,
"filters": [
{
"id": "vlen-utf8"
}
],
"order": "C",
"shape": [
5
],
"zarr_format": 2
}

This file was deleted.

Binary file modified zarrs/tests/data/zarr_python_compat/str_v2_fv_null.zarr/0
Binary file not shown.
Binary file modified zarrs/tests/data/zarr_python_compat/str_v2_fv_null.zarr/1
Binary file not shown.
4 changes: 3 additions & 1 deletion zarrs/tests/zarr_python_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fn zarr_python_compat_fletcher32_v2() -> Result<(), Box<dyn Error>> {
Ok(())
}

// Data generated by v2_str0_zarr_python_v2.py
#[test]
fn zarr_python_v2_compat_str_fv_0() -> Result<(), Box<dyn Error>> {
let store = Arc::new(FilesystemStore::new(
Expand All @@ -53,11 +54,12 @@ fn zarr_python_v2_compat_str_fv_0() -> Result<(), Box<dyn Error>> {
let subset_all = array.subset_all();
let elements = array.retrieve_array_subset_elements::<String>(&subset_all)?;

assert_eq!(elements, &["a", "bb", "", "", ""]);
assert_eq!(elements, &["a", "bb", "", "0", "0"]);

Ok(())
}

// Data generated by v2_str0_zarr_python_v2.py
#[test]
fn zarr_python_v2_compat_str_fv_null() -> Result<(), Box<dyn Error>> {
let store = Arc::new(FilesystemStore::new(
Expand Down

0 comments on commit b100b29

Please sign in to comment.