Skip to content

Commit 4a940b1

Browse files
committed
Remove separators
1 parent edbdb5d commit 4a940b1

3 files changed

Lines changed: 4 additions & 156 deletions

File tree

src/zarr/core/chunk_grids.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
from zarr.core.metadata import ArrayMetadata
3737

3838

39-
# ---------------------------------------------------------------------------
40-
# Per-dimension grid types
41-
# ---------------------------------------------------------------------------
42-
43-
4439
@dataclass(frozen=True)
4540
class FixedDimension:
4641
"""Uniform chunk size. Boundary chunks contain less data but are
@@ -256,11 +251,6 @@ def with_extent(self, new_extent: int) -> DimensionGrid: ...
256251
def resize(self, new_extent: int) -> DimensionGrid: ...
257252

258253

259-
# ---------------------------------------------------------------------------
260-
# ChunkSpec
261-
# ---------------------------------------------------------------------------
262-
263-
264254
@dataclass(frozen=True)
265255
class ChunkSpec:
266256
"""Specification of a single chunk's location and size.
@@ -285,11 +275,6 @@ def is_boundary(self) -> bool:
285275
return self.shape != self.codec_shape
286276

287277

288-
# ---------------------------------------------------------------------------
289-
# RLE helpers (ported from #3534)
290-
# ---------------------------------------------------------------------------
291-
292-
293278
# A single dimension's rectilinear chunk spec: bare int (uniform shorthand),
294279
# list of ints (explicit edges), or mixed RLE (e.g. [[10, 3], 5]).
295280
RectilinearDimSpec = int | list[int | list[int]]
@@ -352,10 +337,6 @@ def _decode_dim_spec(dim_spec: JSON, array_extent: int | None = None) -> list[in
352337
raise ValueError(f"Invalid chunk_shapes entry: {dim_spec}")
353338

354339

355-
# ---------------------------------------------------------------------------
356-
# Unified ChunkGrid
357-
# ---------------------------------------------------------------------------
358-
359340
# Type alias for what users can pass as chunks to create_array
360341
ChunksLike = tuple[int, ...] | list[list[int] | int] | int
361342

@@ -771,11 +752,6 @@ def _infer_chunk_grid_name(
771752
return "regular" if grid.is_regular else "rectilinear"
772753

773754

774-
# ---------------------------------------------------------------------------
775-
# Chunk guessing / normalization (unchanged)
776-
# ---------------------------------------------------------------------------
777-
778-
779755
def _guess_chunks(
780756
shape: tuple[int, ...] | int,
781757
typesize: int,
@@ -999,11 +975,6 @@ def _auto_partition(
999975
return _shards_out, _chunks_out
1000976

1001977

1002-
# ---------------------------------------------------------------------------
1003-
# Backwards-compatibility shim for RegularChunkGrid
1004-
# ---------------------------------------------------------------------------
1005-
1006-
1007978
class _RegularChunkGridMeta(type):
1008979
"""Metaclass that makes ``isinstance(obj, RegularChunkGrid)`` work.
1009980

src/zarr/core/metadata/v3.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@ def parse_extra_fields(
171171
return dict(data)
172172

173173

174-
# ---------------------------------------------------------------------------
175-
# Chunk grid metadata types (pure DTOs — no array shape, no behavioral logic)
176-
# ---------------------------------------------------------------------------
177-
178174
# JSON type for a single dimension's rectilinear spec:
179175
# bare int (uniform shorthand), or list of ints / [value, count] RLE pairs.
180176
RectilinearDimSpecJSON = int | list[int | list[int]]

tests/test_unified_chunk_grid.py

Lines changed: 4 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ def _edges(grid: ChunkGrid, dim: int) -> tuple[int, ...]:
5353
raise TypeError(f"Unexpected dimension type: {type(d)}")
5454

5555

56-
# ---------------------------------------------------------------------------
57-
# Index to chunk
58-
# ---------------------------------------------------------------------------
59-
60-
6156
class TestVaryingDimensionIndexToChunkBounds:
6257
def test_index_at_extent_raises(self) -> None:
6358
"""index_to_chunk(extent) should raise since extent is out of bounds."""
@@ -92,11 +87,6 @@ def test_last_valid_index_works(self) -> None:
9287
assert dim.index_to_chunk(94) == 9
9388

9489

95-
# ---------------------------------------------------------------------------
96-
# Feature flag gating
97-
# ---------------------------------------------------------------------------
98-
99-
10090
class TestRectilinearFeatureFlag:
10191
"""Test that rectilinear chunks are gated behind the config flag."""
10292

@@ -132,11 +122,6 @@ def test_parse_chunk_grid_blocked(self) -> None:
132122
)
133123

134124

135-
# ---------------------------------------------------------------------------
136-
# RegularChunkGrid backwards compatibility
137-
# ---------------------------------------------------------------------------
138-
139-
140125
class TestRegularChunkGridCompat:
141126
"""The deprecated RegularChunkGrid shim should work for common patterns."""
142127

@@ -168,11 +153,6 @@ def test_isinstance_false_for_unrelated_types(self) -> None:
168153
assert not isinstance(42, RegularChunkGrid)
169154

170155

171-
# ---------------------------------------------------------------------------
172-
# FixedDimension
173-
# ---------------------------------------------------------------------------
174-
175-
176156
class TestFixedDimension:
177157
def test_basic(self) -> None:
178158
d = FixedDimension(size=10, extent=100)
@@ -223,11 +203,6 @@ def test_zero_size_allowed(self) -> None:
223203
# ChunkGrid.__getitem__ which checks before delegating.
224204

225205

226-
# ---------------------------------------------------------------------------
227-
# VaryingDimension
228-
# ---------------------------------------------------------------------------
229-
230-
231206
class TestVaryingDimension:
232207
def test_basic(self) -> None:
233208
d = VaryingDimension([10, 20, 30], extent=60)
@@ -279,11 +254,6 @@ def test_zero_edge_rejected(self) -> None:
279254
VaryingDimension([10, 0, 5], extent=15)
280255

281256

282-
# ---------------------------------------------------------------------------
283-
# ChunkSpec
284-
# ---------------------------------------------------------------------------
285-
286-
287257
class TestChunkSpec:
288258
def test_basic(self) -> None:
289259
spec = ChunkSpec(
@@ -302,11 +272,6 @@ def test_boundary(self) -> None:
302272
assert spec.is_boundary
303273

304274

305-
# ---------------------------------------------------------------------------
306-
# ChunkGrid construction
307-
# ---------------------------------------------------------------------------
308-
309-
310275
class TestChunkGridConstruction:
311276
def test_from_regular(self) -> None:
312277
g = ChunkGrid.from_regular((100, 200), (10, 20))
@@ -341,11 +306,6 @@ def test_all_uniform_becomes_regular(self) -> None:
341306
assert g.chunk_shape == (10, 25)
342307

343308

344-
# ---------------------------------------------------------------------------
345-
# ChunkGrid queries
346-
# ---------------------------------------------------------------------------
347-
348-
349309
class TestChunkGridQueries:
350310
def test_regular_shape(self) -> None:
351311
g = ChunkGrid.from_regular((100, 200), (10, 20))
@@ -453,11 +413,6 @@ def test_iter(self) -> None:
453413
assert all(isinstance(s, ChunkSpec) for s in specs)
454414

455415

456-
# ---------------------------------------------------------------------------
457-
# RLE helpers
458-
# ---------------------------------------------------------------------------
459-
460-
461416
class TestRLE:
462417
def test_expand(self) -> None:
463418
assert expand_rle([[10, 3]]) == [10, 10, 10]
@@ -502,19 +457,14 @@ def test_expand_rejects_negative_rle_count(self) -> None:
502457
class TestExpandRleHandlesJsonFloats:
503458
def test_bare_integer_floats_accepted(self) -> None:
504459
"""JSON parsers may emit 10.0 for the integer 10; expand_rle should handle it."""
505-
result = expand_rle([10.0, 20.0])
460+
result = expand_rle([10.0, 20.0]) # type: ignore[list-item]
506461
assert result == [10, 20]
507462

508463
def test_rle_pair_with_float_count(self) -> None:
509-
result = expand_rle([[10, 3.0]])
464+
result = expand_rle([[10, 3.0]]) # type: ignore[list-item]
510465
assert result == [10, 10, 10]
511466

512467

513-
# ---------------------------------------------------------------------------
514-
# _decode_dim_spec edge cases
515-
# ---------------------------------------------------------------------------
516-
517-
518468
class TestDecodeDimSpec:
519469
"""Edge cases for _decode_dim_spec: floats, empty lists, negatives, missing extent."""
520470

@@ -560,11 +510,6 @@ def test_none_raises(self) -> None:
560510
_decode_dim_spec(None, array_extent=10)
561511

562512

563-
# ---------------------------------------------------------------------------
564-
# _is_rectilinear_chunks edge cases
565-
# ---------------------------------------------------------------------------
566-
567-
568513
class TestIsRectilinearChunks:
569514
"""Edge cases for _is_rectilinear_chunks."""
570515

@@ -604,11 +549,6 @@ def test_float(self) -> None:
604549
assert _is_rectilinear_chunks(3.14) is False
605550

606551

607-
# ---------------------------------------------------------------------------
608-
# _infer_chunk_grid_name edge cases
609-
# ---------------------------------------------------------------------------
610-
611-
612552
class TestInferChunkGridName:
613553
"""Edge cases for _infer_chunk_grid_name."""
614554

@@ -639,11 +579,6 @@ def test_dict_with_rectilinear_name(self) -> None:
639579
assert _infer_chunk_grid_name(d, g) == "rectilinear"
640580

641581

642-
# ---------------------------------------------------------------------------
643-
# Serialization
644-
# ---------------------------------------------------------------------------
645-
646-
647582
class TestSerialization:
648583
def test_regular_roundtrip(self) -> None:
649584
g = ChunkGrid.from_regular((100, 200), (10, 20))
@@ -710,7 +645,7 @@ def test_bare_int_roundtrip(self) -> None:
710645
"name": "rectilinear",
711646
"configuration": {"kind": "inline", "chunk_shapes": [10, [20, 30]]},
712647
}
713-
meta = RectilinearChunkGrid.from_dict(data)
648+
meta = RectilinearChunkGrid.from_dict(data) # type: ignore[arg-type]
714649
out = meta.to_dict()
715650
# Dim 0 was bare int — should stay bare int
716651
assert out["configuration"]["chunk_shapes"][0] == 10
@@ -729,7 +664,7 @@ def test_serialize_non_regular_as_regular_raises(self) -> None:
729664
def test_serialize_unknown_name_raises(self) -> None:
730665
g = ChunkGrid.from_regular((100,), (10,))
731666
with pytest.raises(ValueError, match="Unknown chunk grid name for serialization"):
732-
serialize_chunk_grid(g, "hexagonal")
667+
serialize_chunk_grid(g, "hexagonal") # type: ignore[arg-type]
733668

734669
def test_zero_extent_rectilinear_raises(self) -> None:
735670
"""Zero-extent grids cannot be serialized as rectilinear (spec requires positive edges)."""
@@ -924,11 +859,6 @@ def test_single_chunk_boundary_codec_size_preserved(self) -> None:
924859
assert parsed.dimensions[0].chunk_size(0) == 10
925860

926861

927-
# ---------------------------------------------------------------------------
928-
# Indexing with rectilinear grids
929-
# ---------------------------------------------------------------------------
930-
931-
932862
class TestRectilinearIndexing:
933863
"""Test that the indexing pipeline works with VaryingDimension."""
934864

@@ -999,11 +929,6 @@ def test_oob_block_raises_bounds_check_error(self) -> None:
999929
a.get_block_selection((2,))
1000930

1001931

1002-
# ---------------------------------------------------------------------------
1003-
# End-to-end: array creation with rectilinear chunks
1004-
# ---------------------------------------------------------------------------
1005-
1006-
1007932
class TestEndToEnd:
1008933
"""Test creating, writing, and reading arrays with rectilinear chunk grids."""
1009934

@@ -1158,11 +1083,6 @@ def test_get_chunk_spec_rectilinear(self, tmp_path: Path) -> None:
11581083
assert spec2.shape == (30, 50)
11591084

11601085

1161-
# ---------------------------------------------------------------------------
1162-
# Sharding compatibility
1163-
# ---------------------------------------------------------------------------
1164-
1165-
11661086
class TestShardingCompat:
11671087
def test_sharding_accepts_rectilinear_outer_grid(self) -> None:
11681088
"""ShardingCodec.validate should not reject rectilinear outer grids."""
@@ -1180,11 +1100,6 @@ def test_sharding_accepts_rectilinear_outer_grid(self) -> None:
11801100
)
11811101

11821102

1183-
# ---------------------------------------------------------------------------
1184-
# Edge cases
1185-
# ---------------------------------------------------------------------------
1186-
1187-
11881103
class TestEdgeCases:
11891104
"""Edge cases around boundary chunks, zero-size dims, direct construction,
11901105
and serialization round-trips."""
@@ -1562,11 +1477,6 @@ def test_sharding_accepts_divisible_rectilinear(self) -> None:
15621477
)
15631478

15641479

1565-
# ---------------------------------------------------------------------------
1566-
# Full-pipeline read/write tests with rectilinear grids
1567-
# ---------------------------------------------------------------------------
1568-
1569-
15701480
class TestFullPipelineRectilinear:
15711481
"""End-to-end read/write tests through the full Array pipeline."""
15721482

@@ -1900,10 +1810,6 @@ def test_nchunks(self, tmp_path: Path) -> None:
19001810
assert z.chunk_grid.get_nchunks() == 12
19011811

19021812

1903-
# ---------------------------------------------------------------------------
1904-
# Hypothesis property-based tests
1905-
# ---------------------------------------------------------------------------
1906-
19071813
pytest.importorskip("hypothesis")
19081814

19091815
import hypothesis.strategies as st # noqa: E402
@@ -1978,11 +1884,6 @@ def test_property_block_indexing_rectilinear(data: st.DataObject) -> None:
19781884
)
19791885

19801886

1981-
# ---------------------------------------------------------------------------
1982-
# V2 regression tests
1983-
# ---------------------------------------------------------------------------
1984-
1985-
19861887
class TestV2Regression:
19871888
"""Verify V2 arrays still work correctly after the ChunkGrid refactor.
19881889
@@ -2089,11 +1990,6 @@ def test_v2_chunk_spec_via_grid(self, tmp_path: Path) -> None:
20891990
assert spec.codec_shape == (10, 10) # full buffer
20901991

20911992

2092-
# ---------------------------------------------------------------------------
2093-
# .read_chunk_sizes / .write_chunk_sizes properties
2094-
# ---------------------------------------------------------------------------
2095-
2096-
20971993
class TestChunkSizes:
20981994
"""Tests for ChunkGrid.chunk_sizes and Array.read_chunk_sizes / write_chunk_sizes."""
20991995

@@ -2145,11 +2041,6 @@ def test_array_sharded_chunk_sizes(self) -> None:
21452041
assert arr.write_chunk_sizes == ((120,), (80,))
21462042

21472043

2148-
# ---------------------------------------------------------------------------
2149-
# .info display for rectilinear grids
2150-
# ---------------------------------------------------------------------------
2151-
2152-
21532044
def test_info_display_rectilinear() -> None:
21542045
"""Array.info should not crash for rectilinear grids."""
21552046
store = zarr.storage.MemoryStore()
@@ -2166,11 +2057,6 @@ def test_info_display_rectilinear() -> None:
21662057
assert "Array" in text
21672058

21682059

2169-
# ---------------------------------------------------------------------------
2170-
# Resize / append for rectilinear grids
2171-
# ---------------------------------------------------------------------------
2172-
2173-
21742060
class TestUpdateShape:
21752061
"""Unit tests for ChunkGrid.update_shape()."""
21762062

@@ -2454,11 +2340,6 @@ def test_parse_chunk_grid_regular_from_dict(self) -> None:
24542340
assert g.get_nchunks() == 100
24552341

24562342

2457-
# ---------------------------------------------------------------------------
2458-
# Boundary chunk tests
2459-
# ---------------------------------------------------------------------------
2460-
2461-
24622343
class TestVaryingDimensionBoundary:
24632344
"""VaryingDimension with extent < sum(edges), mirroring how FixedDimension
24642345
handles boundary chunks."""

0 commit comments

Comments
 (0)