| 
7 | 7 | import pytest  | 
8 | 8 | from numcodecs import Delta  | 
9 | 9 | from numcodecs.blosc import Blosc  | 
 | 10 | +from numcodecs.zstd import Zstd  | 
10 | 11 | 
 
  | 
11 | 12 | import zarr  | 
12 | 13 | import zarr.core.buffer  | 
13 | 14 | import zarr.storage  | 
14 | 15 | from zarr import config  | 
 | 16 | +from zarr.abc.store import Store  | 
15 | 17 | from zarr.core.buffer.core import default_buffer_prototype  | 
16 | 18 | from zarr.core.sync import sync  | 
17 | 19 | from zarr.storage import MemoryStore, StorePath  | 
@@ -93,11 +95,7 @@ async def test_v2_encode_decode(dtype):  | 
93 | 95 |         store = zarr.storage.MemoryStore()  | 
94 | 96 |         g = zarr.group(store=store, zarr_format=2)  | 
95 | 97 |         g.create_array(  | 
96 |  | -            name="foo",  | 
97 |  | -            shape=(3,),  | 
98 |  | -            chunks=(3,),  | 
99 |  | -            dtype=dtype,  | 
100 |  | -            fill_value=b"X",  | 
 | 98 | +            name="foo", shape=(3,), chunks=(3,), dtype=dtype, fill_value=b"X", compressor=None  | 
101 | 99 |         )  | 
102 | 100 | 
 
  | 
103 | 101 |         result = await store.get("foo/.zarray", zarr.core.buffer.default_buffer_prototype())  | 
@@ -166,6 +164,29 @@ def test_v2_filters_codecs(filters: Any, order: Literal["C", "F"]) -> None:  | 
166 | 164 |     np.testing.assert_array_equal(result, array_fixture)  | 
167 | 165 | 
 
  | 
168 | 166 | 
 
  | 
 | 167 | +@pytest.mark.filterwarnings("ignore")  | 
 | 168 | +@pytest.mark.parametrize("store", ["memory"], indirect=True)  | 
 | 169 | +def test_create_array_defaults(store: Store):  | 
 | 170 | +    """  | 
 | 171 | +    Test that passing compressor=None results in no compressor. Also test that the default value of the compressor  | 
 | 172 | +    parameter does produce a compressor.  | 
 | 173 | +    """  | 
 | 174 | +    g = zarr.open(store, mode="w", zarr_format=2)  | 
 | 175 | +    arr = g.create_array("one", dtype="i8", shape=(1,), chunks=(1,), compressor=None)  | 
 | 176 | +    assert arr._async_array.compressor is None  | 
 | 177 | +    assert not (arr.filters)  | 
 | 178 | +    arr = g.create_array("two", dtype="i8", shape=(1,), chunks=(1,))  | 
 | 179 | +    assert arr._async_array.compressor is not None  | 
 | 180 | +    assert not (arr.filters)  | 
 | 181 | +    arr = g.create_array("three", dtype="i8", shape=(1,), chunks=(1,), compressor=Zstd())  | 
 | 182 | +    assert arr._async_array.compressor is not None  | 
 | 183 | +    assert not (arr.filters)  | 
 | 184 | +    with pytest.raises(ValueError):  | 
 | 185 | +        g.create_array(  | 
 | 186 | +            "four", dtype="i8", shape=(1,), chunks=(1,), compressor=None, compressors=None  | 
 | 187 | +        )  | 
 | 188 | + | 
 | 189 | + | 
169 | 190 | @pytest.mark.parametrize("array_order", ["C", "F"])  | 
170 | 191 | @pytest.mark.parametrize("data_order", ["C", "F"])  | 
171 | 192 | @pytest.mark.parametrize("memory_order", ["C", "F"])  | 
 | 
0 commit comments