Skip to content

Commit a3283a9

Browse files
authored
Merge branch 'main' into feat/default-buffer
2 parents 6b9de9d + 884a8c9 commit a3283a9

File tree

6 files changed

+50
-22
lines changed

6 files changed

+50
-22
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ default_language_version:
1010

1111
repos:
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.14.3
13+
rev: v0.14.10
1414
hooks:
1515
- id: ruff-check
1616
args: ["--fix", "--show-fixes"]
@@ -27,7 +27,7 @@ repos:
2727
exclude: mkdocs.yml
2828
- id: trailing-whitespace
2929
- repo: https://github.com/pre-commit/mirrors-mypy
30-
rev: v1.18.2
30+
rev: v1.19.1
3131
hooks:
3232
- id: mypy
3333
files: src|tests
@@ -46,7 +46,7 @@ repos:
4646
- hypothesis
4747
- s3fs
4848
- repo: https://github.com/scientific-python/cookie
49-
rev: 2025.10.20
49+
rev: 2025.11.21
5050
hooks:
5151
- id: sp-repo-review
5252
- repo: https://github.com/pre-commit/pygrep-hooks
@@ -55,7 +55,7 @@ repos:
5555
- id: rst-directive-colons
5656
- id: rst-inline-touching-normal
5757
- repo: https://github.com/numpy/numpydoc
58-
rev: v1.9.0
58+
rev: v1.10.0
5959
hooks:
6060
- id: numpydoc-validation
6161
- repo: https://github.com/twisted/towncrier

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ ignore_errors = true
395395
minversion = "7"
396396
testpaths = ["tests", "docs/user-guide"]
397397
log_cli_level = "INFO"
398+
log_level = "INFO"
398399
xfail_strict = true
399400
asyncio_mode = "auto"
400401
asyncio_default_fixture_loop_scope = "function"

src/zarr/_cli/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CLIZarrFormatV3(str, Enum):
3535
v3 = "v3"
3636

3737

38-
@app.command() # type: ignore[misc]
38+
@app.command() # type: ignore[untyped-decorator]
3939
def migrate(
4040
zarr_format: Annotated[
4141
CLIZarrFormatV3,
@@ -120,7 +120,7 @@ def migrate(
120120
sync(migrate_metadata.remove_metadata(write_store, 2, force=False, dry_run=dry_run))
121121

122122

123-
@app.command() # type: ignore[misc]
123+
@app.command() # type: ignore[untyped-decorator]
124124
def remove_metadata(
125125
zarr_format: Annotated[
126126
CLIZarrFormat,
@@ -168,7 +168,7 @@ def remove_metadata(
168168
)
169169

170170

171-
@app.callback() # type: ignore[misc]
171+
@app.callback() # type: ignore[untyped-decorator]
172172
def main(
173173
verbose: Annotated[
174174
bool,

src/zarr/core/array.py

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/zarr/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
ChunkCoords = tuple[int, ...]
4343
ZarrFormat = Literal[2, 3]
4444
NodeType = Literal["array", "group"]
45-
JSON = str | int | float | Mapping[str, "JSON"] | Sequence["JSON"] | None
45+
JSON = str | int | float | bool | Mapping[str, "JSON"] | Sequence["JSON"] | None
4646
MemoryOrder = Literal["C", "F"]
4747
AccessModeLiteral = Literal["r", "r+", "a", "w", "w-"]
4848
ANY_ACCESS_MODE: Final = "r", "r+", "a", "w", "w-"

tests/test_metadata/test_v2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,13 @@ def test_from_dict_extra_fields() -> None:
309309

310310

311311
def test_zstd_checksum() -> None:
312+
compressor_config: dict[str, JSON] = {"id": "zstd", "level": 5, "checksum": False}
312313
arr = zarr.create_array(
313314
{},
314315
shape=(10,),
315316
chunks=(10,),
316317
dtype="int32",
317-
compressors={"id": "zstd", "level": 5, "checksum": False},
318+
compressors=compressor_config,
318319
zarr_format=2,
319320
)
320321
metadata = json.loads(

0 commit comments

Comments
 (0)