Skip to content

Commit

Permalink
add compression parameterization
Browse files Browse the repository at this point in the history
  • Loading branch information
rwegener2 committed Dec 14, 2024
1 parent c21547c commit 730c138
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pandas as pd
import pytest
import xarray as xr
from numcodecs import LZ4, Blosc, Zlib, Zstd
from numcodecs.abc import Codec

import zarr

Expand Down Expand Up @@ -60,10 +62,17 @@ def dataset(
return obj


def test_roundtrip(store: zarr.abc.store.Store, dataset: xr.Dataset) -> None:
dataset.to_zarr(store)
@pytest.mark.parametrize("compressor", [Zstd(level=1), LZ4(), Blosc(), Zlib()])
def test_roundtrip_v2(store: zarr.abc.store.Store, dataset: xr.Dataset, compressor: Codec) -> None:
encoding = {
"var1": {
"compressor": compressor,
}
}
dataset.to_zarr(store, encoding=encoding, zarr_format=2)
other_dataset = xr.open_dataset(store, engine="zarr")
assert dataset.identical(other_dataset)
assert isinstance(other_dataset.var1.encoding["compressor"], compressor.__class__)

other_dataset = xr.open_zarr(store)
assert dataset.identical(other_dataset)

0 comments on commit 730c138

Please sign in to comment.