Skip to content

Commit 9e29333

Browse files
d-v-bclaude
andcommitted
test: prefer zero-length axes for stored chunk size 0 in the lifecycle machine
An empty write stores no metadata, so it no longer ends the legacy state. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f081f1b commit 9e29333

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎tests/test_array_stateful.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ def create(self, data: st.DataObject) -> None:
134134
if spelling != "rectilinear" and data.draw(st.booleans(), label="legacy zero"):
135135
# A stored chunk size of 0, as zarr-python wrote for arrays created with a
136136
# zero-length axis; older releases could then grow the axis without storing
137-
# a chunk, so any extent is possible. Sharded arrays store it in the outer grid.
138-
self.legacy_axes = data.draw(
139-
st.lists(st.integers(0, len(shape) - 1), min_size=1, unique=True),
140-
label="axes stored with chunk size 0",
141-
)
137+
# a chunk, so any extent is possible, but zero-length axes come first.
138+
# Sharded arrays store it in the outer grid.
139+
axes = st.lists(st.integers(0, len(shape) - 1), min_size=1, unique=True)
140+
if zero_axes := [axis for axis, extent in enumerate(shape) if extent == 0]:
141+
axes = st.lists(st.sampled_from(zero_axes), min_size=1, unique=True) | axes
142+
self.legacy_axes = data.draw(axes, label="axes stored with chunk size 0")
142143
stored_zero = data.draw(st.sampled_from([0, False]), label="stored zero")
143144
self._rewrite_stored_chunks(zarr_format, self.legacy_axes, stored_zero)
144145
event("legacy zero chunk size")
@@ -269,8 +270,10 @@ def write(self, data: st.DataObject) -> None:
269270
note(f"write {region}")
270271
arr[region] = values
271272
self._model_write(arr, region, values)
272-
# Writing chunks first stores the metadata they are written under.
273-
self.legacy_axes = []
273+
if all(shape):
274+
# Writing chunks first stores the metadata they are written under; a write
275+
# of nothing stores nothing.
276+
self.legacy_axes = []
274277

275278
@precondition(lambda self: self.legacy_axes)
276279
@rule()

0 commit comments

Comments
 (0)