@@ -1256,6 +1256,8 @@ def _shard_grid_shape(self) -> tuple[int, ...]:
12561256 """
12571257 The shape of the shard grid for this array.
12581258
1259+ When no shards are present this will automatically fall back to the chunk grid.
1260+
12591261 Returns
12601262 -------
12611263 tuple[int, ...]
@@ -1287,10 +1289,12 @@ def _nshards(self) -> int:
12871289 """
12881290 The number of shards in this array.
12891291
1292+ If no shards are present this will fall back to giving the number of chunks
1293+
12901294 Returns
12911295 -------
12921296 int
1293- The total number of shards in the array.
1297+ The total number of shards or if absent, chunks in the array.
12941298 """
12951299 return product (self ._shard_grid_shape )
12961300
@@ -1418,6 +1422,8 @@ def _iter_shard_coords(
14181422 """
14191423 Create an iterator over the coordinates of shards in shard grid space.
14201424
1425+ This will fall back to chunk grid space in case no shards are present.
1426+
14211427 Note that
14221428
14231429 If the `origin` keyword is used, iteration will start at the shard index specified by `origin`.
@@ -1436,7 +1442,7 @@ def _iter_shard_coords(
14361442 Yields
14371443 ------
14381444 chunk_coords: tuple[int, ...]
1439- The coordinates of each shard in the selection.
1445+ The coordinates of each shard in the selection or chunk in case of no shard being present .
14401446 """
14411447 return _iter_shard_coords (
14421448 array = self ,
@@ -1450,6 +1456,9 @@ def _iter_shard_keys(
14501456 """
14511457 Iterate over the keys of the stored objects supporting this array.
14521458
1459+ Although only stored objects, e.g. shards should have keys, in case no
1460+ shards are present this automatically falls back to chunks.
1461+
14531462 Parameters
14541463 ----------
14551464 origin : Sequence[int] | None, default=None
@@ -1460,7 +1469,8 @@ def _iter_shard_keys(
14601469 Yields
14611470 ------
14621471 key: str
1463- The storage key of each chunk in the selection.
1472+ The storage key of each shard in the selection or in case of no shard
1473+ present of each chunk although the latter case as technically incorrect.
14641474 """
14651475 # Iterate over the coordinates of chunks in chunk grid space.
14661476 return _iter_shard_keys (
@@ -1499,6 +1509,8 @@ def _iter_shard_regions(
14991509 """
15001510 Iterate over the regions spanned by each shard.
15011511
1512+ This will automatically fall back to chunks if no shards are present.
1513+
15021514 Parameters
15031515 ----------
15041516 origin : Sequence[int] | None, default=None
@@ -1509,7 +1521,8 @@ def _iter_shard_regions(
15091521 Yields
15101522 ------
15111523 region: tuple[slice, ...]
1512- A tuple of slice objects representing the region spanned by each shard in the selection.
1524+ A tuple of slice objects representing the region spanned by each shard in the selection or chunk in the
1525+ absence of shards.
15131526 """
15141527 return _iter_shard_regions (array = self , origin = origin , selection_shape = selection_shape )
15151528
@@ -2591,6 +2604,9 @@ def _iter_shard_keys(
25912604 Iterate over the storage keys of each shard, relative to an optional origin, and optionally
25922605 limited to a contiguous region in chunk grid coordinates.
25932606
2607+ If no shards are present this falls back to chunks, though in this case these are then actually
2608+ not storage keys.
2609+
25942610 Parameters
25952611 ----------
25962612 origin : Sequence[int] | None, default=None
@@ -2601,7 +2617,8 @@ def _iter_shard_keys(
26012617 Yields
26022618 ------
26032619 str
2604- The storage key of each shard in the selection.
2620+ The storage key of each shard in the selection or chunk though chunks technically do not have
2621+ storage keys.
26052622 """
26062623 return self .async_array ._iter_shard_keys (origin = origin , selection_shape = selection_shape )
26072624
@@ -2681,7 +2698,7 @@ def _iter_shard_regions(
26812698 self , origin : Sequence [int ] | None = None , selection_shape : Sequence [int ] | None = None
26822699 ) -> Iterator [tuple [slice , ...]]:
26832700 """
2684- Iterate over the regions spanned by each shard.
2701+ Iterate over the regions spanned by each shard or chunk if no shard is present .
26852702
26862703 Parameters
26872704 ----------
@@ -2693,7 +2710,8 @@ def _iter_shard_regions(
26932710 Yields
26942711 ------
26952712 tuple[slice, ...]
2696- A tuple of slice objects representing the region spanned by each chunk in the selection.
2713+ A tuple of slice objects representing the region spanned by each shard or if no shard is present,
2714+ chunk in the selection.
26972715 """
26982716 return self .async_array ._iter_shard_regions (origin = origin , selection_shape = selection_shape )
26992717
@@ -4226,7 +4244,9 @@ async def _shards_initialized(
42264244 array : AnyAsyncArray ,
42274245) -> tuple [str , ...]:
42284246 """
4229- Return the keys of the chunks that have been persisted to the storage backend.
4247+ Return the keys of the shards that have been persisted to the storage backend.
4248+
4249+ This will fall back to chunks in case no shards are present.
42304250
42314251 Parameters
42324252 ----------
@@ -4236,7 +4256,7 @@ async def _shards_initialized(
42364256 Returns
42374257 -------
42384258 chunks_initialized : tuple[str, ...]
4239- The keys of the chunks that have been initialized.
4259+ The keys of the shards or if these are not present, chunks that have been initialized.
42404260
42414261 Related
42424262 -------
@@ -5381,6 +5401,8 @@ def _iter_shard_coords(
53815401 If the `selection_shape` keyword is used, iteration will be bounded over a contiguous region
53825402 ranging from `[origin, origin selection_shape]`, where the upper bound is exclusive as
53835403 per python indexing conventions.
5404+ If no shards are present this will iterate over the coordinates of chunks in chunk grid space
5405+ instead.
53845406
53855407 Parameters
53865408 ----------
@@ -5394,7 +5416,7 @@ def _iter_shard_coords(
53945416 Yields
53955417 ------
53965418 chunk_coords: tuple[int, ...]
5397- The coordinates of each shard in the selection.
5419+ The coordinates of each shard in the selection or chunks if no shards are present .
53985420 """
53995421 return _iter_grid (array ._shard_grid_shape , origin = origin , selection_shape = selection_shape )
54005422
@@ -5409,6 +5431,8 @@ def _iter_shard_keys(
54095431 Iterate over the storage keys of each shard, relative to an optional origin, and optionally
54105432 limited to a contiguous region in shard grid coordinates.
54115433
5434+ This automatically falls back to chunks when no shards are present.
5435+
54125436 Parameters
54135437 ----------
54145438 array : Array | AsyncArray
@@ -5421,7 +5445,7 @@ def _iter_shard_keys(
54215445 Yields
54225446 ------
54235447 key: str
5424- The storage key of each chunk in the selection.
5448+ The storage key of each shard in the selection or chunk when no shards are present .
54255449 """
54265450 # Iterate over the coordinates of chunks in chunk grid space.
54275451 _iter = _iter_grid (array ._shard_grid_shape , origin = origin , selection_shape = selection_shape )
@@ -5437,7 +5461,8 @@ def _iter_shard_regions(
54375461 """
54385462 Iterate over the regions spanned by each shard.
54395463
5440- These are the smallest regions of the array that are safe to write concurrently.
5464+ These are the smallest regions of the array that are safe to write concurrently. When
5465+ no shards are present this will fall back to chunks.
54415466
54425467 Parameters
54435468 ----------
@@ -5451,7 +5476,8 @@ def _iter_shard_regions(
54515476 Yields
54525477 ------
54535478 region: tuple[slice, ...]
5454- A tuple of slice objects representing the region spanned by each shard in the selection.
5479+ A tuple of slice objects representing the region spanned by each shard in the selection or chunk
5480+ when no shards are present.
54555481 """
54565482 if array .shards is None :
54575483 shard_shape = array .chunks
0 commit comments