Skip to content

Commit 26d5e96

Browse files
ieivanovclaude
andcommitted
tighten hypothesis index strategies to sorted, unique lists
apply_transform_czyx_setup and process_single_position_setup now draw integer time_indices / channel_indices with unique=True and .map(sorted). That matches the pattern real callers pass and keeps the oindex selectors on the zarrs fast path -- unsorted or duplicate integer arrays cause ZarrsCodecPipeline to raise UnsupportedVIndexingError and fall back to BatchedCodecPipeline, which hits zarr-developers/zarr-python#2834 on sharded v0.5 stores (tracked in iohub#404). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a9a4a84 commit 26d5e96

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

tests/ngff/test_ngff_utils.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ def apply_transform_czyx_setup(draw):
281281
) = draw(plate_setup())
282282
T, C = shape[:2]
283283

284-
# Define a helper strategy to generate channel indices based on C
284+
# Define a helper strategy to generate channel indices based on C.
285+
# Integer lists are drawn ``unique=True`` and sorted: zarrs only accelerates
286+
# monotonically-increasing unique oindex selectors and falls back to the
287+
# buggy BatchedCodecPipeline (zarr-python#2834 / iohub#404) for duplicate
288+
# or unsorted inputs.
285289
channel_indices_strategy = st.one_of(
286290
st.builds(
287291
slice,
@@ -293,15 +297,17 @@ def apply_transform_czyx_setup(draw):
293297
st.integers(min_value=0, max_value=C - 1),
294298
min_size=1,
295299
max_size=min(3, C),
296-
),
300+
unique=True,
301+
).map(sorted),
297302
)
298303

299304
time_indices_strategy = st.one_of(
300305
st.lists(
301306
st.integers(min_value=0, max_value=T - 1),
302307
min_size=1,
303308
max_size=min(3, T),
304-
),
309+
unique=True,
310+
).map(sorted),
305311
)
306312

307313
# Generate input and output channel indices based on C
@@ -357,7 +363,11 @@ def process_single_position_setup(draw):
357363

358364
T, C = shape[:2]
359365

360-
# Define a helper strategy to generate channel indices based on C
366+
# Define a helper strategy to generate channel indices based on C.
367+
# Integer lists are drawn ``unique=True`` and sorted: zarrs only accelerates
368+
# monotonically-increasing unique oindex selectors and falls back to the
369+
# buggy BatchedCodecPipeline (zarr-python#2834 / iohub#404) for duplicate
370+
# or unsorted inputs.
361371
channel_indices_strategy = st.one_of(
362372
st.none(),
363373
st.lists(
@@ -375,8 +385,8 @@ def process_single_position_setup(draw):
375385
st.integers(min_value=0, max_value=C - 1),
376386
min_size=1,
377387
max_size=C,
378-
# ensure each inner list has one element),
379-
),
388+
unique=True,
389+
).map(sorted),
380390
min_size=1,
381391
max_size=min(3, C),
382392
),
@@ -388,7 +398,8 @@ def process_single_position_setup(draw):
388398
st.integers(min_value=0, max_value=T - 1),
389399
min_size=1,
390400
max_size=min(3, T),
391-
),
401+
unique=True,
402+
).map(sorted),
392403
)
393404

394405
# Generate input and output channel indices based on C

0 commit comments

Comments
 (0)