@@ -70,7 +70,7 @@ def test_guess_chunks(shape: tuple[int, ...], itemsize: int) -> None:
7070def test_normalize_chunks (
7171 chunks : Any , shape : tuple [int , ...], expected : tuple [tuple [int , ...], ...]
7272) -> None :
73- assert expected == normalize_chunks_nd (chunks , shape )
73+ _assert_chunks_equal ( normalize_chunks_nd (chunks , shape ), expected )
7474
7575
7676@pytest .mark .parametrize (
@@ -97,12 +97,12 @@ def test_resolve_outer_and_inner_chunks(
9797 outer_chunks , inner = resolve_outer_and_inner_chunks (
9898 array_shape = array_shape , chunks = chunks , shard_shape = shard_shape , item_size = 1
9999 )
100- assert outer_chunks == expected_outer
100+ _assert_chunks_equal ( outer_chunks , expected_outer )
101101 if expected_inner_outer is None :
102102 assert inner is None
103103 else :
104104 assert inner is not None
105- assert inner .outer_chunks == expected_inner_outer
105+ _assert_chunks_equal ( inner .outer_chunks , expected_inner_outer )
106106 assert inner .inner is None
107107
108108
@@ -118,11 +118,11 @@ def test_resolved_chunking_nested() -> None:
118118 top = ResolvedChunking (outer_chunks = normalize_chunks_nd ((50 , 50 ), (100 , 100 )), inner = mid )
119119
120120 # Three levels: top -> mid -> leaf
121- assert top .outer_chunks == ((50 , 50 ), (50 , 50 ))
121+ _assert_chunks_equal ( top .outer_chunks , ((50 , 50 ), (50 , 50 ) ))
122122 assert top .inner is not None
123- assert top .inner .outer_chunks == ((25 ,) * 4 , (25 ,) * 4 )
123+ _assert_chunks_equal ( top .inner .outer_chunks , ((25 ,) * 4 , (25 ,) * 4 ) )
124124 assert top .inner .inner is not None
125- assert top .inner .inner .outer_chunks == ((5 ,) * 20 , (5 ,) * 20 )
125+ _assert_chunks_equal ( top .inner .inner .outer_chunks , ((5 ,) * 20 , (5 ,) * 20 ) )
126126 assert top .inner .inner .inner is None
127127
128128
@@ -150,3 +150,36 @@ def test_normalize_chunks_errors() -> None:
150150 normalize_chunks_nd ((100 , 10 ), (100 ,))
151151 with pytest .raises (ValueError , match = "dimensions" ):
152152 normalize_chunks_nd ((10 ,), (100 , 100 ))
153+
154+
155+ def test_normalize_chunks_1d_uniform_returns_int64_array () -> None :
156+ """The uniform-chunks branch must return a 1D int64 array — this is the
157+ representation that enables O(1) construction via np.full."""
158+ from zarr .core .chunk_grids import normalize_chunks_1d
159+
160+ result = normalize_chunks_1d (1000 , 100_000 )
161+ assert isinstance (result , np .ndarray )
162+ assert result .dtype == np .int64
163+ assert result .ndim == 1
164+ assert result .shape == (100 ,)
165+ assert (result == 1000 ).all ()
166+
167+
168+ def test_normalize_chunks_1d_explicit_list_returns_int64_array () -> None :
169+ """The explicit-per-chunk branch must also produce an int64 array."""
170+ from zarr .core .chunk_grids import normalize_chunks_1d
171+
172+ result = normalize_chunks_1d ([10 , 20 , 30 , 40 ], 100 )
173+ assert isinstance (result , np .ndarray )
174+ assert result .dtype == np .int64
175+ assert result .tolist () == [10 , 20 , 30 , 40 ]
176+
177+
178+ def test_normalize_chunks_1d_full_span_returns_int64_array () -> None :
179+ """The -1 sentinel branch must also produce an int64 array."""
180+ from zarr .core .chunk_grids import normalize_chunks_1d
181+
182+ result = normalize_chunks_1d (- 1 , 100 )
183+ assert isinstance (result , np .ndarray )
184+ assert result .dtype == np .int64
185+ assert result .tolist () == [100 ]
0 commit comments