Skip to content

Commit

Permalink
(fix): compression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold committed Jan 14, 2025
1 parent f1ca6f7 commit 3dc87a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/anndata/_io/specs/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ def write_vlen_string_array_zarr(
from numcodecs import VLenUTF8
from zarr.codecs import VLenUTF8Codec

dataset_kwargs = dataset_kwargs.copy()
if "compressor" in dataset_kwargs:
dataset_kwargs.pop("compressor")
f.create_array(
k,
shape=elem.shape,
Expand Down Expand Up @@ -1165,6 +1168,7 @@ def _remove_scalar_compression_args(dataset_kwargs: Mapping[str, Any]) -> dict:
"shuffle",
"fletcher32",
"scaleoffset",
"compressor",
):
dataset_kwargs.pop(arg, None)
return dataset_kwargs
Expand Down
9 changes: 5 additions & 4 deletions tests/test_readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,14 @@ def test_zarr_compression(tmp_path):

ad.io.write_zarr(pth, adata, compressor=compressor)

def check_compressed(key, value):
if isinstance(value, zarr.Array) and value.shape != ():
def check_compressed(value, key):
if value.shape != ():
if value.compressor != compressor:
not_compressed.append(key)

with zarr.open(str(pth), "r") as f:
f.visititems(check_compressed)
f = zarr.open(str(pth), "r")
for key in f.array_keys():
check_compressed(f[key], key)

if not_compressed:
msg = "\n\t".join(not_compressed)
Expand Down

0 comments on commit 3dc87a3

Please sign in to comment.