File tree Expand file tree Collapse file tree 4 files changed +27
-24
lines changed Expand file tree Collapse file tree 4 files changed +27
-24
lines changed Original file line number Diff line number Diff 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_dtype_kind_to_default_filters_and_compressor " : {
68- "biufcmM " : ["zstd" ],
69- "U " : ["vlen-utf8" ],
70- "OSV " : ["vlen-bytes" ],
67+ "v2_default_compressors " : {
68+ "numeric " : ["zstd" ],
69+ "unicode " : ["vlen-utf8" ],
70+ "bytes " : ["vlen-bytes" ],
7171 },
7272 }
7373 ],
Original file line number Diff line number Diff line change @@ -341,13 +341,16 @@ def _default_filters_and_compressor(
341341) -> tuple [list [dict [str , str ]], dict [str , str ] | None ]:
342342 """Get the default filters and compressor for a dtype.
343343
344- The config contains a mapping from numpy dtype kind to the default compressor.
345344 https://numpy.org/doc/2.1/reference/generated/numpy.dtype.kind.html
346345 """
347- dtype_kind_to_default_compressor = config .get ("v2_dtype_kind_to_default_filters_and_compressor" )
348- for dtype_kinds , filters_and_compressor in dtype_kind_to_default_compressor .items ():
349- if dtype .kind in dtype_kinds :
350- filters = [{"id" : f } for f in filters_and_compressor ]
351- compressor = None
352- return filters , compressor
353- return [], None
346+ default_compressors = config .get ("v2_default_compressors" )
347+ if dtype .kind in "biufcmM" :
348+ dtype_key = "numeric"
349+ elif dtype .kind in "U" :
350+ dtype_key = "unicode"
351+ elif dtype .kind in "OSV" :
352+ dtype_key = "bytes"
353+ else :
354+ raise ValueError (f"Unsupported dtype kind { dtype .kind } " )
355+
356+ return [{"id" : f } for f in default_compressors [dtype_key ]], None
Original file line number Diff line number Diff 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_dtype_kind_to_default_filters_and_compressor " : {
67- "biufcmM " : ["zstd" ],
68- "U " : ["vlen-utf8" ],
69- "OSV " : ["vlen-bytes" ],
66+ "v2_default_compressors " : {
67+ "numeric " : ["zstd" ],
68+ "unicode " : ["vlen-utf8" ],
69+ "bytes " : ["vlen-bytes" ],
7070 },
7171 }
7272 ]
Original file line number Diff line number Diff line change @@ -84,8 +84,8 @@ def test_codec_pipeline() -> None:
8484async def test_v2_encode_decode (dtype ):
8585 with config .set (
8686 {
87- "v2_dtype_kind_to_default_filters_and_compressor " : {
88- "SV " : ["vlen-bytes" ],
87+ "v2_default_compressors " : {
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_dtype_kind_to_default_filters_and_compressor " : {
130- "U " : ["vlen-utf8" ],
131- "OSV " : ["vlen-bytes" ],
129+ "v2_default_compressors " : {
130+ "unicode " : ["vlen-utf8" ],
131+ "bytes " : ["vlen-bytes" ],
132132 },
133133 }
134134 ):
@@ -171,9 +171,9 @@ def test_default_filters_and_compressor(dtype_expected: Any) -> None:
171171 with config .set (
172172 {
173173 "v2_dtype_kind_to_default_filters_and_compressor" : {
174- "biufcmM " : ["zstd" ],
175- "U " : ["vlen-utf8" ],
176- "OSV " : ["vlen-bytes" ],
174+ "numeric " : ["zstd" ],
175+ "unicode " : ["vlen-utf8" ],
176+ "bytes " : ["vlen-bytes" ],
177177 },
178178 }
179179 ):
You can’t perform that action at this time.
0 commit comments