@@ -1346,18 +1346,53 @@ def info(self) -> Any:
13461346 AsyncArray.info_complete
13471347 All information about a group, including dynamic information
13481348 like the number of bytes and chunks written.
1349+
1350+ Examples
1351+ --------
1352+
1353+ >>> arr = await zarr.api.asynchronous.create(
1354+ ... path="array", shape=(3, 4, 5), chunks=(2, 2, 2))
1355+ ... )
1356+ >>> arr.info
1357+ Type : Array
1358+ Zarr format : 3
1359+ Data type : DataType.float64
1360+ Shape : (3, 4, 5)
1361+ Chunk shape : (2, 2, 2)
1362+ Order : C
1363+ Read-only : False
1364+ Store type : MemoryStore
1365+ Codecs : [{'endian': <Endian.little: 'little'>}]
1366+ No. bytes : 480
13491367 """
13501368 return self ._info ()
13511369
13521370 async def info_complete (self ) -> Any :
1353- # TODO: get the size of the object from the store.
1354- extra = {
1355- "count_chunks_initialized" : await self .nchunks_initialized (),
1356- # count_bytes_stored isn't yet implemented.
1357- }
1358- return self ._info (extra = extra )
1359-
1360- def _info (self , extra : dict [str , int ] | None = None ) -> Any :
1371+ """
1372+ Return all the information for an array, including dynamic information like a storage size.
1373+
1374+ In addition to the static information, this provides
1375+
1376+ - The count of chunks initialized
1377+ - The sum of the bytes written
1378+
1379+ Returns
1380+ -------
1381+ ArrayInfo
1382+
1383+ See Also
1384+ --------
1385+ AsyncArray.info
1386+ A property giving just the statically known information about an array.
1387+ """
1388+ return self ._info (
1389+ await self .nchunks_initialized (),
1390+ await self .store_path .store .getsize_prefix (self .store_path .path ),
1391+ )
1392+
1393+ def _info (
1394+ self , count_chunks_initialized : int | None = None , count_bytes_stored : int | None = None
1395+ ) -> Any :
13611396 kwargs : dict [str , Any ] = {}
13621397 if self .metadata .zarr_format == 2 :
13631398 assert isinstance (self .metadata , ArrayV2Metadata )
@@ -1386,6 +1421,8 @@ def _info(self, extra: dict[str, int] | None = None) -> Any:
13861421 _read_only = self .read_only ,
13871422 _store_type = type (self .store_path .store ).__name__ ,
13881423 _count_bytes = self .dtype .itemsize * self .size ,
1424+ _count_bytes_stored = count_bytes_stored ,
1425+ _count_chunks_initialized = count_chunks_initialized ,
13891426 ** kwargs ,
13901427 )
13911428
@@ -2844,6 +2881,14 @@ def set_coordinate_selection(
28442881 if hasattr (value , "shape" ) and len (value .shape ) > 1 :
28452882 value = np .array (value ).reshape (- 1 )
28462883
2884+ if not is_scalar (value , self .dtype ) and (
2885+ isinstance (value , NDArrayLike ) and indexer .shape != value .shape
2886+ ):
2887+ raise ValueError (
2888+ f"Attempting to set a selection of { indexer .sel_shape [0 ]} "
2889+ f"elements with an array of { value .shape [0 ]} elements."
2890+ )
2891+
28472892 sync (self ._async_array ._set_selection (indexer , value , fields = fields , prototype = prototype ))
28482893
28492894 @_deprecate_positional_args
0 commit comments