@@ -324,24 +324,46 @@ def test_serializable_sync_array(store: LocalStore, zarr_format: ZarrFormat) ->
324324
325325
326326@pytest .mark .parametrize ("store" , ["memory" ], indirect = True )
327- def test_storage_transformers (store : MemoryStore ) -> None :
327+ @pytest .mark .parametrize ("zarr_format" , [2 , 3 , "invalid" ])
328+ def test_storage_transformers (store : MemoryStore , zarr_format ) -> None :
328329 """
329330 Test that providing an actual storage transformer produces a warning and otherwise passes through
330331 """
331- metadata_dict : dict [str , JSON ] = {
332- "zarr_format" : 3 ,
333- "node_type" : "array" ,
334- "shape" : (10 ,),
335- "chunk_grid" : {"name" : "regular" , "configuration" : {"chunk_shape" : (1 ,)}},
336- "data_type" : "uint8" ,
337- "chunk_key_encoding" : {"name" : "v2" , "configuration" : {"separator" : "/" }},
338- "codecs" : (BytesCodec ().to_dict (),),
339- "fill_value" : 0 ,
340- "storage_transformers" : ({"test" : "should_raise" }),
341- }
342- match = "Arrays with storage transformers are not supported in zarr-python at this time."
343- with pytest .raises (ValueError , match = match ):
332+ if zarr_format == 3 :
333+ metadata_dict : dict [str , JSON ] = {
334+ "zarr_format" : 3 ,
335+ "node_type" : "array" ,
336+ "shape" : (10 ,),
337+ "chunk_grid" : {"name" : "regular" , "configuration" : {"chunk_shape" : (1 ,)}},
338+ "data_type" : "uint8" ,
339+ "chunk_key_encoding" : {"name" : "v2" , "configuration" : {"separator" : "/" }},
340+ "codecs" : (BytesCodec ().to_dict (),),
341+ "fill_value" : 0 ,
342+ "storage_transformers" : ({"test" : "should_raise" }),
343+ }
344+ else :
345+ metadata_dict : dict [str , JSON ] = {
346+ "zarr_format" : zarr_format ,
347+ "shape" : (10 ,),
348+ "chunks" : (1 ,),
349+ "dtype" : "uint8" ,
350+ "dimension_separator" : "." ,
351+ "codecs" : (BytesCodec ().to_dict (),),
352+ "fill_value" : 0 ,
353+ "order" : "C" ,
354+ "storage_transformers" : ({"test" : "should_raise" }),
355+ }
356+ if zarr_format == 3 :
357+ match = "Arrays with storage transformers are not supported in zarr-python at this time."
358+ with pytest .raises (ValueError , match = match ):
359+ Array .from_dict (StorePath (store ), data = metadata_dict )
360+ elif zarr_format == 2 :
361+ # no warning
344362 Array .from_dict (StorePath (store ), data = metadata_dict )
363+ else :
364+ match = f"Invalid zarr_format: { zarr_format } . Expected 2 or 3"
365+ with pytest .raises (ValueError , match = match ):
366+ Array .from_dict (StorePath (store ), data = metadata_dict )
345367
346368
347369@pytest .mark .parametrize ("test_cls" , [Array , AsyncArray [Any ]])
0 commit comments