Skip to content

Commit a77fb0d

Browse files
committed
allow only one default compressor
1 parent 75a858d commit a77fb0d

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/zarr/api/asynchronous.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ async def create(
822822
- For numeric arrays, the default is `ZstdCodec`.
823823
- For Unicode strings, the default is `VLenUTF8Codec`.
824824
- For bytes or objects, the default is `VLenBytesCodec`.
825-
These defaults can be changed using the `v2_default_compressors` variable in the Zarr config.
825+
These defaults can be changed using the `v2_default_compressor` variable in the Zarr config.
826826
fill_value : object
827827
Default value to use for uninitialized portions of the array.
828828
order : {'C', 'F'}, optional
@@ -898,7 +898,7 @@ async def create(
898898
dtype = parse_dtype(dtype, zarr_format)
899899
if not filters and not compressor:
900900
filters, compressor = _default_filters_and_compressor(dtype)
901-
elif zarr_format == 3 and chunk_shape is None: #type: ignore[redundant-expr]
901+
elif zarr_format == 3 and chunk_shape is None: # type: ignore[redundant-expr]
902902
if chunks is not None:
903903
chunk_shape = chunks
904904
chunks = None

src/zarr/core/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ def reset(self) -> None:
6464
},
6565
"buffer": "zarr.core.buffer.cpu.Buffer",
6666
"ndbuffer": "zarr.core.buffer.cpu.NDBuffer",
67-
"v2_default_compressors": {
68-
"numeric": ["zstd"],
69-
"unicode": ["vlen-utf8"],
70-
"bytes": ["vlen-bytes"],
67+
"v2_default_compressor": {
68+
"numeric": "zstd",
69+
"string": "vlen-utf8",
70+
"bytes": "vlen-bytes",
7171
},
7272
}
7373
],

src/zarr/core/metadata/v2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ def _default_filters_and_compressor(
337337
https://numpy.org/doc/2.1/reference/generated/numpy.dtype.kind.html
338338
"""
339339
dtype = np.dtype(dtype)
340-
default_compressors = config.get("v2_default_compressors")
340+
default_compressor = config.get("v2_default_compressor")
341341
if dtype.kind in "biufcmM":
342342
dtype_key = "numeric"
343343
elif dtype.kind in "U":
344-
dtype_key = "unicode"
344+
dtype_key = "string"
345345
elif dtype.kind in "OSV":
346346
dtype_key = "bytes"
347347
else:
348348
raise ValueError(f"Unsupported dtype kind {dtype.kind}")
349349

350-
return [{"id": f} for f in default_compressors[dtype_key]], None
350+
return [{"id": default_compressor[dtype_key]}], None

tests/test_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def test_config_defaults_set() -> None:
6363
"vlen-utf8": "zarr.codecs.vlen_utf8.VLenUTF8Codec",
6464
"vlen-bytes": "zarr.codecs.vlen_utf8.VLenBytesCodec",
6565
},
66-
"v2_default_compressors": {
67-
"numeric": ["zstd"],
68-
"unicode": ["vlen-utf8"],
69-
"bytes": ["vlen-bytes"],
66+
"v2_default_compressor": {
67+
"numeric": "zstd",
68+
"string": "vlen-utf8",
69+
"bytes": "vlen-bytes",
7070
},
7171
}
7272
]

tests/test_v2.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def test_codec_pipeline() -> None:
8484
async def test_v2_encode_decode(dtype):
8585
with config.set(
8686
{
87-
"v2_default_compressors": {
88-
"bytes": ["vlen-bytes"],
87+
"v2_default_compressor": {
88+
"bytes": "vlen-bytes",
8989
},
9090
}
9191
):
@@ -126,9 +126,9 @@ def test_v2_encode_decode_with_data(dtype_value):
126126
dtype, value = dtype_value
127127
with config.set(
128128
{
129-
"v2_default_compressors": {
130-
"unicode": ["vlen-utf8"],
131-
"bytes": ["vlen-bytes"],
129+
"v2_default_compressor": {
130+
"string": "vlen-utf8",
131+
"bytes": "vlen-bytes",
132132
},
133133
}
134134
):
@@ -215,10 +215,10 @@ def test_v2_non_contiguous(array_order: Literal["C", "F"], data_order: Literal["
215215
def test_default_filters_and_compressor(dtype_expected: Any) -> None:
216216
with config.set(
217217
{
218-
"v2_dtype_kind_to_default_filters_and_compressor": {
219-
"numeric": ["zstd"],
220-
"unicode": ["vlen-utf8"],
221-
"bytes": ["vlen-bytes"],
218+
"v2_default_compressor": {
219+
"numeric": "zstd",
220+
"string": "vlen-utf8",
221+
"bytes": "vlen-bytes",
222222
},
223223
}
224224
):

0 commit comments

Comments
 (0)