File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,13 @@ def _json_convert(
116116 else :
117117 return o .descr
118118 if isinstance (o , numcodecs .abc .Codec ):
119- return o .get_config ()
119+ codec_config = o .get_config ()
120+
121+ # Hotfix for https://github.com/zarr-developers/zarr-python/issues/2647
122+ if codec_config ["id" ] == "zstd" and not codec_config .get ("checksum" , False ):
123+ codec_config .pop ("checksum" , None )
124+
125+ return codec_config
120126 if np .isscalar (o ):
121127 out : Any
122128 if hasattr (o , "dtype" ) and o .dtype .kind == "M" and hasattr (o , "view" ):
Original file line number Diff line number Diff line change 99import zarr .api .asynchronous
1010import zarr .storage
1111from zarr .core .buffer import cpu
12+ from zarr .core .buffer .core import default_buffer_prototype
1213from zarr .core .group import ConsolidatedMetadata , GroupMetadata
1314from zarr .core .metadata import ArrayV2Metadata
1415from zarr .core .metadata .v2 import parse_zarr_format
@@ -282,3 +283,18 @@ def test_from_dict_extra_fields() -> None:
282283 order = "C" ,
283284 )
284285 assert result == expected
286+
287+
288+ def test_zstd_checksum () -> None :
289+ arr = zarr .create_array (
290+ {},
291+ shape = (10 ,),
292+ chunks = (10 ,),
293+ dtype = "int32" ,
294+ compressors = {"id" : "zstd" , "level" : 5 , "checksum" : False },
295+ zarr_format = 2 ,
296+ )
297+ metadata = json .loads (
298+ arr .metadata .to_buffer_dict (default_buffer_prototype ())[".zarray" ].to_bytes ()
299+ )
300+ assert "checksum" not in metadata ["compressor" ]
You can’t perform that action at this time.
0 commit comments