Skip to content

Commit b934471

Browse files
authored
Merge branch 'main' into ig/spec0_py314
2 parents 00afc6c + ee0e69a commit b934471

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

changes/3603.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Correct the target bytes number for auto-chunking when auto-sharding.

changes/3605.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug in the test suite that prevented stand-alone example scripts from being tested.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test = [
7575
"coverage>=7.10",
7676
# Pin possibly due to https://github.com/pytest-dev/pytest-cov/issues/693
7777
"pytest<8.4",
78-
"pytest-asyncio",
78+
"pytest-asyncio<1.2.0",
7979
"pytest-cov",
8080
"pytest-accept",
8181
"rich",

src/zarr/core/chunk_grids.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def _guess_chunks(
6262
tuple[int, ...]
6363
6464
"""
65+
if min_bytes >= max_bytes:
66+
raise ValueError(f"Cannot have more min_bytes ({min_bytes}) than max_bytes ({max_bytes})")
6567
if isinstance(shape, int):
6668
shape = (shape,)
6769

@@ -264,7 +266,7 @@ def _auto_partition(
264266
else:
265267
if chunk_shape == "auto":
266268
# aim for a 1MiB chunk
267-
_chunks_out = _guess_chunks(array_shape, item_size, max_bytes=1024)
269+
_chunks_out = _guess_chunks(array_shape, item_size, max_bytes=1048576)
268270
else:
269271
_chunks_out = chunk_shape
270272

tests/test_array.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,24 @@ def test_auto_partition_auto_shards(
10191019
assert auto_shards == expected_shards
10201020

10211021

1022+
def test_auto_partition_auto_shards_with_auto_chunks_should_be_close_to_1MiB() -> None:
1023+
"""
1024+
Test that automatically picking a shard size and a chunk size gives roughly 1MiB chunks.
1025+
"""
1026+
with pytest.warns(
1027+
ZarrUserWarning,
1028+
match="Automatic shard shape inference is experimental and may change without notice.",
1029+
):
1030+
with zarr.config.set({"array.target_shard_size_bytes": 10_000_000}):
1031+
_, chunk_shape = _auto_partition(
1032+
array_shape=(10_000_000,),
1033+
chunk_shape="auto",
1034+
shard_shape="auto",
1035+
item_size=1,
1036+
)
1037+
assert chunk_shape == (625000,)
1038+
1039+
10221040
def test_chunks_and_shards() -> None:
10231041
store = StorePath(MemoryStore())
10241042
shape = (100, 100)

tests/test_examples.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from packaging.requirements import Requirement
1212

1313
examples_dir = "examples"
14-
script_paths = Path(examples_dir).glob("*.py")
14+
script_paths = tuple(Path(examples_dir).rglob("*.py"))
1515

1616
PEP_723_REGEX: Final = r"(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$"
1717

@@ -62,6 +62,13 @@ def resave_script(source_path: Path, dest_path: Path) -> None:
6262
dest_path.write_text(dest_text)
6363

6464

65+
def test_script_paths() -> None:
66+
"""
67+
Test that our test fixture is working properly and collecting script paths.
68+
"""
69+
assert len(script_paths) > 0
70+
71+
6572
@pytest.mark.skipif(
6673
sys.platform in ("win32",), reason="This test fails due for unknown reasons on Windows in CI."
6774
)

0 commit comments

Comments
 (0)