@@ -46,7 +46,7 @@ def _enable_rectilinear_chunks() -> Generator[None, None, None]:
4646
4747def _edges (grid : ChunkGrid , dim : int ) -> tuple [int , ...]:
4848 """Extract the per-chunk edge lengths for *dim* from a ChunkGrid."""
49- d = grid .dimensions [dim ]
49+ d = grid ._dimensions [dim ]
5050 if isinstance (d , FixedDimension ):
5151 return tuple (d .size for _ in range (d .nchunks ))
5252 if isinstance (d , VaryingDimension ):
@@ -327,8 +327,8 @@ def test_chunk_grid_construction(
327327def test_chunk_grid_rectilinear_uniform_dim_is_fixed () -> None :
328328 """A rectilinear grid with all-same sizes in one dim stores it as Fixed."""
329329 g = ChunkGrid .from_sizes ((60 , 100 ), [[10 , 20 , 30 ], [25 , 25 , 25 , 25 ]])
330- assert isinstance (g .dimensions [0 ], VaryingDimension )
331- assert isinstance (g .dimensions [1 ], FixedDimension )
330+ assert isinstance (g ._dimensions [0 ], VaryingDimension )
331+ assert isinstance (g ._dimensions [1 ], FixedDimension )
332332
333333
334334# ---------------------------------------------------------------------------
@@ -715,7 +715,7 @@ def test_parse_chunk_grid_varying_extent_mismatch_raises() -> None:
715715 with pytest .raises (ValueError , match = "extent" ):
716716 ChunkGrid (
717717 dimensions = tuple (
718- dim .with_extent (ext ) for dim , ext in zip (g .dimensions , (100 , 100 ), strict = True )
718+ dim .with_extent (ext ) for dim , ext in zip (g ._dimensions , (100 , 100 ), strict = True )
719719 )
720720 )
721721
@@ -725,10 +725,10 @@ def test_parse_chunk_grid_varying_extent_match_ok() -> None:
725725 g = ChunkGrid .from_sizes ((60 , 100 ), [[10 , 20 , 30 ], [50 , 50 ]])
726726 g2 = ChunkGrid (
727727 dimensions = tuple (
728- dim .with_extent (ext ) for dim , ext in zip (g .dimensions , (60 , 100 ), strict = True )
728+ dim .with_extent (ext ) for dim , ext in zip (g ._dimensions , (60 , 100 ), strict = True )
729729 )
730730 )
731- assert g2 .dimensions [0 ].extent == 60
731+ assert g2 ._dimensions [0 ].extent == 60
732732
733733
734734@pytest .mark .parametrize (
@@ -793,7 +793,7 @@ def test_parse_chunk_grid_varying_dimension_extent_mismatch_on_chunkgrid_input()
793793 with pytest .raises (ValueError , match = "less than" ):
794794 ChunkGrid (
795795 dimensions = tuple (
796- dim .with_extent (ext ) for dim , ext in zip (g .dimensions , (100 , 50 ), strict = True )
796+ dim .with_extent (ext ) for dim , ext in zip (g ._dimensions , (100 , 50 ), strict = True )
797797 )
798798 )
799799
@@ -1126,30 +1126,30 @@ def test_0d_grid_nchunks() -> None:
11261126def test_parse_chunk_grid_preserves_varying_extent () -> None :
11271127 """parse_chunk_grid does not overwrite VaryingDimension extent."""
11281128 g = ChunkGrid .from_sizes ((60 , 100 ), [[10 , 20 , 30 ], [50 , 50 ]])
1129- assert isinstance (g .dimensions [0 ], VaryingDimension )
1130- assert g .dimensions [0 ].extent == 60
1129+ assert isinstance (g ._dimensions [0 ], VaryingDimension )
1130+ assert g ._dimensions [0 ].extent == 60
11311131
11321132 g2 = ChunkGrid (
11331133 dimensions = tuple (
1134- dim .with_extent (ext ) for dim , ext in zip (g .dimensions , (60 , 100 ), strict = True )
1134+ dim .with_extent (ext ) for dim , ext in zip (g ._dimensions , (60 , 100 ), strict = True )
11351135 )
11361136 )
1137- assert isinstance (g2 .dimensions [0 ], VaryingDimension )
1138- assert g2 .dimensions [0 ].extent == 60
1137+ assert isinstance (g2 ._dimensions [0 ], VaryingDimension )
1138+ assert g2 ._dimensions [0 ].extent == 60
11391139
11401140
11411141def test_parse_chunk_grid_rebinds_fixed_extent () -> None :
11421142 """parse_chunk_grid updates FixedDimension extent from array shape."""
11431143 g = ChunkGrid .from_sizes ((100 , 200 ), (10 , 20 ))
1144- assert g .dimensions [0 ].extent == 100
1144+ assert g ._dimensions [0 ].extent == 100
11451145
11461146 g2 = ChunkGrid (
11471147 dimensions = tuple (
1148- dim .with_extent (ext ) for dim , ext in zip (g .dimensions , (50 , 100 ), strict = True )
1148+ dim .with_extent (ext ) for dim , ext in zip (g ._dimensions , (50 , 100 ), strict = True )
11491149 )
11501150 )
1151- assert isinstance (g2 .dimensions [0 ], FixedDimension )
1152- assert g2 .dimensions [0 ].extent == 50
1151+ assert isinstance (g2 ._dimensions [0 ], FixedDimension )
1152+ assert g2 ._dimensions [0 ].extent == 50
11531153 assert g2 .grid_shape == (5 , 5 )
11541154
11551155
@@ -1775,7 +1775,7 @@ def test_varying_dimension_interior_chunk_spec() -> None:
17751775def test_overflow_multiple_chunks_past_extent () -> None :
17761776 """Edges past extent are structural; nchunks counts active only."""
17771777 g = ChunkGrid .from_sizes ((50 ,), [[10 , 20 , 30 , 40 ]])
1778- d = g .dimensions [0 ]
1778+ d = g ._dimensions [0 ]
17791779 assert d .ngridcells == 4
17801780 assert d .nchunks == 3
17811781 assert d .data_size (0 ) == 10
@@ -1821,10 +1821,10 @@ def test_overflow_multidim() -> None:
18211821def test_overflow_uniform_edges_collapses_to_fixed () -> None :
18221822 """Uniform edges where len == ceildiv(extent, edge) collapse to FixedDimension."""
18231823 g = ChunkGrid .from_sizes ((35 ,), [[10 , 10 , 10 , 10 ]])
1824- assert isinstance (g .dimensions [0 ], FixedDimension )
1824+ assert isinstance (g ._dimensions [0 ], FixedDimension )
18251825 assert g .is_regular
18261826 assert g .chunk_sizes == ((10 , 10 , 10 , 5 ),)
1827- assert g .dimensions [0 ].nchunks == 4
1827+ assert g ._dimensions [0 ].nchunks == 4
18281828
18291829
18301830def test_overflow_index_to_chunk_near_extent () -> None :
@@ -2009,7 +2009,7 @@ def test_update_shape_shrink_single_dim() -> None:
20092009 grid = ChunkGrid .from_sizes ((100 , 50 ), [[10 , 20 , 30 , 40 ], [25 , 25 ]])
20102010 new_grid = grid .update_shape ((35 , 50 ))
20112011 assert _edges (new_grid , 0 ) == (10 , 20 , 30 , 40 )
2012- assert new_grid .dimensions [0 ].nchunks == 3
2012+ assert new_grid ._dimensions [0 ].nchunks == 3
20132013 assert _edges (new_grid , 1 ) == (25 , 25 )
20142014
20152015
@@ -2018,7 +2018,7 @@ def test_update_shape_shrink_to_single_chunk() -> None:
20182018 grid = ChunkGrid .from_sizes ((60 , 50 ), [[10 , 20 , 30 ], [25 , 25 ]])
20192019 new_grid = grid .update_shape ((5 , 50 ))
20202020 assert _edges (new_grid , 0 ) == (10 , 20 , 30 )
2021- assert new_grid .dimensions [0 ].nchunks == 1
2021+ assert new_grid ._dimensions [0 ].nchunks == 1
20222022 assert _edges (new_grid , 1 ) == (25 , 25 )
20232023
20242024
@@ -2027,9 +2027,9 @@ def test_update_shape_shrink_multiple_dims() -> None:
20272027 grid = ChunkGrid .from_sizes ((40 , 60 ), [[10 , 10 , 15 , 5 ], [20 , 25 , 15 ]])
20282028 new_grid = grid .update_shape ((25 , 35 ))
20292029 assert _edges (new_grid , 0 ) == (10 , 10 , 15 , 5 )
2030- assert new_grid .dimensions [0 ].nchunks == 3
2030+ assert new_grid ._dimensions [0 ].nchunks == 3
20312031 assert _edges (new_grid , 1 ) == (20 , 25 , 15 )
2032- assert new_grid .dimensions [1 ].nchunks == 2
2032+ assert new_grid ._dimensions [1 ].nchunks == 2
20332033
20342034
20352035def test_update_shape_dimension_mismatch_error () -> None :
@@ -2049,9 +2049,9 @@ def test_update_shape_boundary_cases() -> None:
20492049 grid2 = ChunkGrid .from_sizes ((60 , 50 ), [[10 , 20 , 30 ], [15 , 25 , 10 ]])
20502050 new_grid2 = grid2 .update_shape ((30 , 40 ))
20512051 assert _edges (new_grid2 , 0 ) == (10 , 20 , 30 )
2052- assert new_grid2 .dimensions [0 ].nchunks == 2
2052+ assert new_grid2 ._dimensions [0 ].nchunks == 2
20532053 assert _edges (new_grid2 , 1 ) == (15 , 25 , 10 )
2054- assert new_grid2 .dimensions [1 ].nchunks == 2
2054+ assert new_grid2 ._dimensions [1 ].nchunks == 2
20552055
20562056
20572057def test_update_shape_regular_preserves_extents (tmp_path : Path ) -> None :
@@ -2065,7 +2065,7 @@ def test_update_shape_regular_preserves_extents(tmp_path: Path) -> None:
20652065 z [:] = np .arange (100 , dtype = "int32" )
20662066 z .resize (50 )
20672067 assert z .shape == (50 ,)
2068- assert ChunkGrid .from_metadata (z .metadata ).dimensions [0 ].extent == 50
2068+ assert ChunkGrid .from_metadata (z .metadata )._dimensions [0 ].extent == 50
20692069
20702070
20712071# ---------------------------------------------------------------------------
@@ -2077,7 +2077,7 @@ def test_update_shape_shrink_creates_boundary() -> None:
20772077 """Shrinking extent into a chunk creates a boundary with clipped data_size"""
20782078 grid = ChunkGrid .from_sizes ((60 ,), [[10 , 20 , 30 ]])
20792079 new_grid = grid .update_shape ((45 ,))
2080- dim = new_grid .dimensions [0 ]
2080+ dim = new_grid ._dimensions [0 ]
20812081 assert isinstance (dim , VaryingDimension )
20822082 assert dim .edges == (10 , 20 , 30 )
20832083 assert dim .extent == 45
@@ -2089,7 +2089,7 @@ def test_update_shape_shrink_to_exact_boundary() -> None:
20892089 """Shrinking to an exact chunk boundary reduces nchunks without partial data"""
20902090 grid = ChunkGrid .from_sizes ((60 ,), [[10 , 20 , 30 ]])
20912091 new_grid = grid .update_shape ((30 ,))
2092- dim = new_grid .dimensions [0 ]
2092+ dim = new_grid ._dimensions [0 ]
20932093 assert isinstance (dim , VaryingDimension )
20942094 assert dim .edges == (10 , 20 , 30 )
20952095 assert dim .nchunks == 2
@@ -2113,9 +2113,11 @@ def test_update_shape_parse_chunk_grid_rebinds_extent() -> None:
21132113 """parse_chunk_grid re-binds VaryingDimension extent to array shape."""
21142114 g = ChunkGrid .from_sizes ((60 ,), [[10 , 20 , 30 ]])
21152115 g2 = ChunkGrid (
2116- dimensions = tuple (dim .with_extent (ext ) for dim , ext in zip (g .dimensions , (50 ,), strict = True ))
2116+ dimensions = tuple (
2117+ dim .with_extent (ext ) for dim , ext in zip (g ._dimensions , (50 ,), strict = True )
2118+ )
21172119 )
2118- dim = g2 .dimensions [0 ]
2120+ dim = g2 ._dimensions [0 ]
21192121 assert isinstance (dim , VaryingDimension )
21202122 assert dim .extent == 50
21212123 assert dim .data_size (2 ) == 20
@@ -2364,7 +2366,7 @@ def test_v2_chunk_grid_is_regular(tmp_path: Path) -> None:
23642366 assert grid .is_regular
23652367 assert grid .chunk_shape == (10 , 15 )
23662368 assert grid .grid_shape == (2 , 2 )
2367- assert all (isinstance (d , FixedDimension ) for d in grid .dimensions )
2369+ assert all (isinstance (d , FixedDimension ) for d in grid ._dimensions )
23682370
23692371
23702372def test_v2_boundary_chunks (tmp_path : Path ) -> None :
@@ -2377,9 +2379,9 @@ def test_v2_boundary_chunks(tmp_path: Path) -> None:
23772379 zarr_format = 2 ,
23782380 )
23792381 grid = ChunkGrid .from_metadata (a .metadata )
2380- assert grid .dimensions [0 ].nchunks == 3
2381- assert grid .dimensions [0 ].chunk_size (2 ) == 10
2382- assert grid .dimensions [0 ].data_size (2 ) == 5
2382+ assert grid ._dimensions [0 ].nchunks == 3
2383+ assert grid ._dimensions [0 ].chunk_size (2 ) == 10
2384+ assert grid ._dimensions [0 ].data_size (2 ) == 5
23832385
23842386
23852387def test_v2_slicing_with_boundary (tmp_path : Path ) -> None :
@@ -2714,7 +2716,7 @@ def test_property_block_indexing_rectilinear(data: st.DataObject) -> None:
27142716 grid = ChunkGrid .from_metadata (z .metadata )
27152717
27162718 for dim in range (a .ndim ):
2717- dim_grid = grid .dimensions [dim ]
2719+ dim_grid = grid ._dimensions [dim ]
27182720 block_ix = data .draw (st .integers (min_value = 0 , max_value = dim_grid .nchunks - 1 ))
27192721 sel = [slice (None )] * a .ndim
27202722 start = dim_grid .chunk_offset (block_ix )
0 commit comments