@@ -479,15 +479,26 @@ def test_update_attrs(zarr_format: ZarrFormat) -> None:
479479 assert arr2 .attrs ["foo" ] == "bar"
480480
481481
482+ @pytest .mark .parametrize (("chunks" , "shards" ), [((2 , 2 ), None ), (2 , 2 ), (4 , 4 )])
482483class TestInfo :
484+ chunks : tuple [int , int ]
485+ shards : tuple [int , int ] | None
486+
487+ def __init__ (self , chunks : tuple [int , int ], shards : tuple [int , int ] | None ) -> None :
488+ self .chunks = chunks
489+ self .shards = shards
490+
483491 def test_info_v2 (self ) -> None :
484- arr = zarr .create (shape = (4 , 4 ), chunks = (2 , 2 ), zarr_format = 2 )
492+ arr = zarr .create_array (
493+ store = {}, shape = (8 , 8 ), dtype = "f8" , chunks = self .chunks , zarr_format = 2
494+ )
485495 result = arr .info
486496 expected = ArrayInfo (
487497 _zarr_format = 2 ,
488498 _data_type = np .dtype ("float64" ),
489- _shape = (4 , 4 ),
490- _chunk_shape = (2 , 2 ),
499+ _shape = (8 , 8 ),
500+ _chunk_shape = self .chunks ,
501+ _shard_shape = None ,
491502 _order = "C" ,
492503 _read_only = False ,
493504 _store_type = "MemoryStore" ,
@@ -497,12 +508,14 @@ def test_info_v2(self) -> None:
497508 assert result == expected
498509
499510 def test_info_v3 (self ) -> None :
500- arr = zarr .create (shape = (4 , 4 ), chunks = (2 , 2 ), zarr_format = 3 )
511+ arr = zarr .create_array (
512+ store = {}, shape = (8 , 8 ), dtype = "f8" , chunks = self .chunks , shards = self .shards
513+ )
501514 result = arr .info
502515 expected = ArrayInfo (
503516 _zarr_format = 3 ,
504517 _data_type = DataType .parse ("float64" ),
505- _shape = (4 , 4 ),
518+ _shape = (8 , 8 ),
506519 _chunk_shape = (2 , 2 ),
507520 _order = "C" ,
508521 _read_only = False ,
@@ -513,13 +526,21 @@ def test_info_v3(self) -> None:
513526 assert result == expected
514527
515528 def test_info_complete (self ) -> None :
516- arr = zarr .create (shape = (4 , 4 ), chunks = (2 , 2 ), zarr_format = 3 , codecs = [BytesCodec ()])
529+ arr = zarr .create_array (
530+ store = {},
531+ shape = (8 , 8 ),
532+ dtype = "f8" ,
533+ chunks = self .chunks ,
534+ shards = self .shards ,
535+ compressors = None ,
536+ )
517537 result = arr .info_complete ()
518538 expected = ArrayInfo (
519539 _zarr_format = 3 ,
520540 _data_type = DataType .parse ("float64" ),
521- _shape = (4 , 4 ),
522- _chunk_shape = (2 , 2 ),
541+ _shape = (8 , 8 ),
542+ _chunk_shape = self .chunks ,
543+ _shard_shape = self .shards ,
523544 _order = "C" ,
524545 _read_only = False ,
525546 _store_type = "MemoryStore" ,
@@ -538,13 +559,16 @@ def test_info_complete(self) -> None:
538559 assert result == expected
539560
540561 async def test_info_v2_async (self ) -> None :
541- arr = await zarr .api .asynchronous .create (shape = (4 , 4 ), chunks = (2 , 2 ), zarr_format = 2 )
562+ arr = await zarr .api .asynchronous .create_array (
563+ store = {}, shape = (8 , 8 ), dtype = "f8" , chunks = self .chunks , zarr_format = 2
564+ )
542565 result = arr .info
543566 expected = ArrayInfo (
544567 _zarr_format = 2 ,
545568 _data_type = np .dtype ("float64" ),
546- _shape = (4 , 4 ),
569+ _shape = (8 , 8 ),
547570 _chunk_shape = (2 , 2 ),
571+ _shard_shape = None ,
548572 _order = "C" ,
549573 _read_only = False ,
550574 _store_type = "MemoryStore" ,
@@ -554,13 +578,20 @@ async def test_info_v2_async(self) -> None:
554578 assert result == expected
555579
556580 async def test_info_v3_async (self ) -> None :
557- arr = await zarr .api .asynchronous .create (shape = (4 , 4 ), chunks = (2 , 2 ), zarr_format = 3 )
581+ arr = await zarr .api .asynchronous .create_array (
582+ store = {},
583+ shape = (8 , 8 ),
584+ dtype = "f8" ,
585+ chunks = self .chunks ,
586+ shards = self .shards ,
587+ )
558588 result = arr .info
559589 expected = ArrayInfo (
560590 _zarr_format = 3 ,
561591 _data_type = DataType .parse ("float64" ),
562- _shape = (4 , 4 ),
563- _chunk_shape = (2 , 2 ),
592+ _shape = (8 , 8 ),
593+ _chunk_shape = self .chunks ,
594+ _shard_shape = self .shards ,
564595 _order = "C" ,
565596 _read_only = False ,
566597 _store_type = "MemoryStore" ,
@@ -570,15 +601,21 @@ async def test_info_v3_async(self) -> None:
570601 assert result == expected
571602
572603 async def test_info_complete_async (self ) -> None :
573- arr = await zarr .api .asynchronous .create (
574- shape = (4 , 4 ), chunks = (2 , 2 ), zarr_format = 3 , codecs = [BytesCodec ()]
604+ arr = await zarr .api .asynchronous .create_array (
605+ store = {},
606+ dtype = "f8" ,
607+ shape = (8 , 8 ),
608+ chunks = self .chunks ,
609+ shards = self .shards ,
610+ compressors = None ,
575611 )
576612 result = await arr .info_complete ()
577613 expected = ArrayInfo (
578614 _zarr_format = 3 ,
579615 _data_type = DataType .parse ("float64" ),
580- _shape = (4 , 4 ),
581- _chunk_shape = (2 , 2 ),
616+ _shape = (8 , 8 ),
617+ _chunk_shape = self .chunks ,
618+ _shard_shape = self .shards ,
582619 _order = "C" ,
583620 _read_only = False ,
584621 _store_type = "MemoryStore" ,
0 commit comments