Commit 51033fb
refactor(sharding): store chunks_per_shard explicitly in _ShardIndex (zarr-developers#3975)
* refactor(sharding): store chunks_per_shard explicitly in _ShardIndex
_ShardIndex previously inferred the chunk grid shape from
offsets_and_lengths.shape[:-1]. For 0-D arrays this collapses the array
to rank-1, breaking methods that assume rank >= 2 and forcing a numpy
compat cast workaround.
Store chunks_per_shard as an explicit NamedTuple field instead. This
removes the chunks_per_shard property and its cast, and lets several
call sites use the field directly instead of reverse-engineering it.
Also fix a latent 0-D bug in is_dense, which iterated offsets_and_lengths
assuming rank-2.
Closes zarr-developers#3974
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test: parametrize over dimensionalities
* refactor(sharding): store chunks_per_shard explicitly in _ShardIndex
_ShardIndex previously inferred the chunk grid shape from
offsets_and_lengths.shape[:-1]. For 0-D arrays this collapses the array
to rank-1, breaking methods that assume rank >= 2 and forcing a numpy
compat cast workaround.
Store chunks_per_shard as an explicit NamedTuple field instead. This
removes the chunks_per_shard property and its cast, and lets several
call sites use the field directly instead of reverse-engineering it.
Also fix a latent 0-D bug in is_dense, which iterated offsets_and_lengths
assuming rank-2.
Tests for get_chunk_slices_vectorized, _ShardReader.__iter__, and
is_dense are parametrized over chunk grid ranks (0-D, 1-D, 2-D) so 0-D
is exercised as a normal case rather than a special branch.
Closes zarr-developers#3974
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* remove is_dense
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cdb5846 commit 51033fb
3 files changed
Lines changed: 55 additions & 67 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| 125 | + | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | 130 | | |
136 | 131 | | |
137 | 132 | | |
138 | | - | |
| 133 | + | |
139 | 134 | | |
140 | 135 | | |
141 | 136 | | |
| |||
171 | 166 | | |
172 | 167 | | |
173 | 168 | | |
174 | | - | |
| 169 | + | |
| 170 | + | |
175 | 171 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
193 | 187 | | |
194 | 188 | | |
195 | 189 | | |
| |||
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | 208 | | |
236 | 209 | | |
237 | 210 | | |
238 | 211 | | |
239 | | - | |
| 212 | + | |
240 | 213 | | |
241 | 214 | | |
242 | 215 | | |
| |||
280 | 253 | | |
281 | 254 | | |
282 | 255 | | |
283 | | - | |
| 256 | + | |
284 | 257 | | |
285 | 258 | | |
286 | 259 | | |
| |||
298 | 271 | | |
299 | 272 | | |
300 | 273 | | |
301 | | - | |
302 | | - | |
| 274 | + | |
303 | 275 | | |
304 | 276 | | |
305 | 277 | | |
| |||
712 | 684 | | |
713 | 685 | | |
714 | 686 | | |
715 | | - | |
| 687 | + | |
716 | 688 | | |
717 | 689 | | |
718 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
567 | 568 | | |
568 | 569 | | |
569 | 570 | | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
0 commit comments