Skip to content

feat(array): define ArrayIO and AsyncArrayIO as protocols in zarr.abc.array_io - #470

Draft
d-v-b wants to merge 31 commits into
mainfrom
claude/array-on-arrayio
Draft

d-v-b wants to merge 31 commits into
mainfrom
claude/array-on-arrayio

Conversation

@d-v-b

@d-v-b d-v-b commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Add zarr.abc.array_io, an interface of protocols for reading and writing an array as a value: AsyncArrayIO, ArrayIO (its synchronous counterpart), ArrayResult (what reads return) and ArrayData (what writes accept). zarr-python implements it with AsyncZarrArrayIO and ZarrArrayIO, which AsyncArray reads and writes through; Array and AsyncArray behave as before.

Related work: this replaces the approach of #447 (a private binding under AsyncArray), and #419 and #420 stay parked. It overlaps with upstream zarr-developers#4034. The branch is based on this fork's main at b0020f2e2. Data that broadcasts across more than one chunk along a broadcast axis fails inside the shared write path, for Array and ArrayIO alike; #472 fixes that separately.

For the zarrista maintainer (agent)

The protocols are written so that a zarrista Array / AsyncArray could satisfy them, and so that zarr-python could later wrap zarrista. An agent type-checked zarrista 0.1.0's stubs against them with mypy, one protocol member at a time. Properties (metadata, attrs, shape), with_attrs, erase_metadata and the selections already conform. The protocol was loosened where the difference was incidental: JSON values are object, and ArrayResult asks only for __array__, because zarrista's variable-length tensors have no DLPack.

These differences remain. Each could be resolved on either side.

Member zarr.abc.array_io zarrista 0.1.0
retrieve_* / __getitem__, return ArrayResult (anything with __array__) FixedLengthTensor | VariableLengthTensor | OptionalFixedLengthTensor | OptionalVariableLengthTensor; OptionalVariableLengthTensor has no __array__
Options keywords read_missing_chunks: bool = True and store_empty_chunks: bool = False **codec_options: Unpack[CodecOptions], with no option for missing chunks
store_metadata() returns the value as stored returns None
Chunk indices Sequence[int] list[int] (a stub could say Sequence[int])
with_shape takes Sequence[int] takes list[int]
erase_chunks an iterable of chunk indices a selection (array subset)
store_chunk data ArrayData (a DLPack array) ArrayBytes
needs_repair property; False for an implementation that repairs nothing absent
metadata a document with tuples and storage_transformers: () lists, no storage_transformers; store_metadata adds a _zarrs attribute
All-fill chunks with a NaN fill any NaN counts as the fill value, so the chunk is not stored and reads back the fill's NaN bits compared bit for bit, so a NaN with other bits is stored
SupportsDLPack __dlpack__(*, stream, max_version, dl_device, copy), the array API keywords __dlpack__(**kwargs: object) -> object

On the last row: under zarrista's stub, a producer that exports through DLPack with the array API's keywords fails to type-check as write data, so store_array_subset does not conform yet. PyTorch and JAX tensors are such producers, and NumPy arrays pass zarrista's stub only because they are also Buffers. A protocol with the explicit keywords (as here, and as NumPy's from_dlpack stub has it) accepts all of them.

Four things that used to differ are now left out of the interface or made to match, so that the same call means the same thing to both implementations. tests/test_array_io_zarrista.py checks this by running the same calls through both (below).

  • Selections. The interface takes only array subsets (slices with a step of 1 and Ellipsis), which both read and write with the subset's shape, and leaves integers out, because zarr-python drops an integer's axis as NumPy does and zarrista keeps it as a range of length 1 (checked at runtime with 0.1.0). zarrista accepts more selectors than the interface asks for, so it conforms; zarr-python's implementations refuse integers (TypeError) and other steps (ValueError), so code that runs against them runs the same against zarrista. NumPy indexing stays in zarr.Array, a layer above the interface. Slice bounds are read as NumPy reads them (negative bounds count from the end, bounds past the end are clipped), which both already do; the type of the error for a refused selection is not part of the interface (zarr-python raises ValueError for a step, zarrista NotImplementedError).
  • Write data. ArrayData is now only SupportsDLPack, with exactly the region's shape and the array's data type. Before, it included Buffer, and the same call stored different values: b"12" written to a uint8 (2,) array was one value to zarr-python ([12, 12]) and two raw bytes to zarrista ([49, 50]). zarr-python also broadcast scalars and cast data types where zarrista refuses them. ZarrArrayIO now refuses lists, scalars, byte buffers, other shapes and other data types; zarr.Array keeps broadcasting and casting. An implementation may refuse a data type it cannot import: zarrista writes strings only as ArrayBytes, while ZarrArrayIO writes them from a NumPy array of the array's string data type.
  • path. zarrista gives '/' and '/g/a' where zarr-python gives '' and 'g/a'. With the store private, path is an implementation attribute, not part of the interface.
  • Edge chunks. retrieve_chunk and store_chunk now use the chunk's full shape, padding included, as zarrs does; zarr-python used to give and take only the part inside the array (retrieve_chunk([2]) of a (5,) array with chunks (2,) was [5], now [5, fill], as in zarrista), for sharded and transposed arrays too. What the padding of a stored chunk reads as, and whether it counts when deciding that a chunk holds only the fill value, is not part of the interface (zarrs stores what it is given there; zarr-python stores the fill value).
  • Byte order. Write data in either byte order is converted to the array's, since DLPack carries only native byte order. Data must otherwise be C-ordered for zarrista, which refuses other layouts; the interface allows that refusal.
API (agent)

zarr.abc.array_io holds the interface only. How a value is made is not part of the interface, so each implementation has its own constructors.

Change metadata with_shape(shape), with_attrs(attrs) (replaces): new values, nothing stored
Store and delete store_metadata() (returns the stored value), erase_metadata(), erase_chunk(indices), erase_chunks(indices)
Read and write retrieve_array_subset, store_array_subset, retrieve_chunk, store_chunk, io[...] (and io[...] = data on ArrayIO). Reads take read_missing_chunks (default True; False raises for a missing chunk), writes take store_empty_chunks (default False).
Inspect metadata (a document), attrs, shape, needs_repair
Selections array subsets: slices with a step of 1 and Ellipsis; data has the subset's shape. Integers are not selections (implementations differ on whether one keeps its axis); select one element with slice(i, i + 1).
Data reads return ArrayResult, anything numpy.asarray accepts; writes take ArrayData, an array that exports through DLPack with exactly the region's shape and the array's data type (nothing is broadcast or cast)

zarr-python's implementations, AsyncZarrArrayIO and ZarrArrayIO in zarr.core.array, add:

  • constructors: open(store, path="", *, zarr_format=None), from_metadata(metadata, store, path="") (stores and checks nothing) and of(array) (a snapshot of an Array or AsyncArray); calling the class raises;
  • ArrayIO.as_async() and AsyncArrayIO.as_sync(context=...) to switch between the two.

The store is an implementation detail: the constructors take one, but no value exposes it. path is on the implementations only.

Their reads return NumPy arrays, 0-d for a 0-d array. Writes read host data with __array__ through numpy.asarray (so NumPy string and record arrays, which DLPack cannot carry, are written), view other host DLPack producers through numpy.from_dlpack, and pass device arrays with __array__ (CuPy) on to the prototype.

  • Values are stateless: fields are private, equality is identity, and attributes are deep-copied wherever a value takes them in or hands them out. An older value still describes the array as it was, and storing its metadata replaces newer metadata; that is part of the API.
  • Nothing is repaired implicitly. A value opened from a document whose repair moves chunks (a stored chunk size of 0, read as 1) has needs_repair. Storing chunks raises MetadataRepairRequiredError until store_metadata() has stored the repair; the value it returns writes chunks.
  • Writes refuse data that is not a DLPack array or is of another data type (TypeError), or of another shape (ValueError); nothing is broadcast or cast, and byte order is converted. Chunk methods take non-negative indices, one for each dimension, and read and write the chunk's full shape. Reads and writes need indices inside the chunk grid; erasing does not.
  • A value holds no runtime configuration: each read or write takes its own options, not the global configuration and not the configuration of the array a value was taken from. Data reads in C order, except that a Zarr format 2 array keeps the order its metadata declares.
  • ZarrArrayIO runs coroutines through SyncContext(runner=...). A runner is anything with run(coro), such as asyncio.Runner(); the default runs on zarr's IO loop. The runner is the seam for a sync-native implementation later.
  • AsyncArray builds an AsyncZarrArrayIO from its fields for each operation and keeps its own repair hooks; Array is byte-identical to main.
  • Nothing is exported from zarr yet.
Testing and review (agent)
  • The full suite passes (13,515 passed); tests/test_array_io.py has 116 tests. mypy is clean, and a static assignment in the tests checks that ZarrArrayIO and AsyncZarrArrayIO satisfy the protocols.
  • tools/compat (2,000 seeds, 150,430 steps, plus pickles in both directions) against the fork's main: the only differences are 10 scenario steps and 2 pickle steps where an AsyncArray subclass that is already broken on main fails with an AttributeError naming a different missing attribute.
  • zarrista conformance, types: an agent generated one protocol per member and type-checked zarrista 0.1.0's stubs against each with mypy.
  • zarrista conformance, behavior: tests/test_array_io_zarrista.py (31 tests) runs the same reads and writes through ZarrArrayIO and zarrista on 7 data types across regular, big-endian, transposed and sharded layouts: whole, partial, clipped and empty subset writes, a full edge chunk, all-fill chunks and subsets with and without store_empty_chunks, and an erase. After each step both must read bit-identical values, subsets and chunks, each must read the other's store the same way, and both must have stored the same chunk keys; both must refuse data of another data type or shape. Mutants (trimmed edge chunks, an ignored big-endian codec, -0.0 fills, ignored store_empty_chunks) all fail it. zarrista is in a zarrista-tests dependency group installed by the optional rows of the hatch test matrix (not min_deps: zarrista needs NumPy 2.1 and typing_extensions 4.16).
  • Adversarial review ran in rounds with fresh reviewers given the diff; each finding was reproduced before it was fixed.
    • Earlier rounds, before the protocols: design audits found the keyword constructor taking derived fields (49854fad9), the mismatch with zarrista's model (aed95d8ba), and attributes shared through nested values, unchecked erase indices, global configuration and silently dropped extra write data (869da17c8). A casting check added in 869da17c8 refused valid writes and let lossy ones through; it was replaced by a shape check (6bb24a3d3, 0ad8b6ef8). Broadcasting write data to the region (968d103bb) materialized whole regions; the check now only validates (31cacfa3e). Two later rounds found nothing serious (test gaps covered in 1a69bf5c5, e90a6b915).
    • Protocols, round 1 (three serious findings, all fixed in bf5cc0aea):
      • integer reads were rebuilt from a scalar, which cut trailing NULs from strings and lost byte order and the prototype's array kind;
      • the DLPack test fake failed under NumPy 2.0;
      • writes sent anything with __dlpack__ through np.from_dlpack, which refused pyarrow arrays with nulls or strings that Array accepts.
        Minor findings fixed in the same commit: an unclear error for DLPack-only data off the host, a DLPack promise for every numeric result that NumPy's non-native byte orders break, and stale fragment text.
    • Protocols, round 2: nothing serious. The protocol now says that an implementation may refuse data on a device it cannot read, and that bytes is one value (bf5cc0aea). The GPU default prototype is an open decision below; nested variable-length-bytes reads are an existing bug, listed below.
    • Round 3 ran on the CPU-default commit, which is held locally: in GPU mode every sharded read and write would raise, so that commit waits for fix(codecs): build buffers from the given prototype instead of zarr.config #474.
    • Round 4, on narrowing selections and making the store private (d0cef561a, 4549282b4): nothing serious in that diff. It found that bytes write data was one value to zarr-python and two raw bytes to zarrista (fixed by exact DLPack writes, b3145acdb), that path differs (dropped from the protocols, 961ba8f45), and that slice bounds and refusal error types were unstated (ae0e3e1f2).
    • Round 5, on exact writes: two serious findings. On Zarr format 3 the accepted byte order depended on how the value was made (of or open), fixed in 30a7a76e7; edge chunks had different shapes in the two implementations, fixed by copying zarrs (928e55ba3). Minor: data not in C order and out-of-grid chunks are now documented as outside the interface (30a7a76e7). Because each round found a new difference, the differential test was added (652211974).
    • Round 6, on those fixes and the test: three serious findings. Data in the other byte order reached numcodecs filters unconverted and was stored byte-swapped (fixed in 5fc05be5b); zarrista in the test group made min_deps unresolvable, and the test could not see a codec bug that is wrong the same way on write and read (both fixed in 4e99606ef, which also compares bits and covers store_empty_chunks). Minor findings fixed in the same commits: subarray byte order, v2 edge-chunk memory order, the padding wording.
    • Round 7, on the round-6 fix diff only: nothing serious. Minor: the dev group lost zarrista, so local runs skipped the test (fixed in 15d853b46).
    • Round 8, on 15d853b46 only: nothing serious (free-threaded 3.13t/3.15t would build zarrista from source; no CI job uses them). Two rounds in a row found nothing serious, so review stopped here.
Open decisions (agent)
  • The resolutions to the remaining differences with zarrista above.
  • The implementation class names: ZarrArrayIO and AsyncZarrArrayIO for now.
  • Decided: ZarrArrayIO reads and writes will default to the CPU buffer prototype, not zarr.config's. The commit is held locally (not on this branch) because the sharding codec refuses any prototype but the configured one, so in GPU mode every sharded read and write would raise; a separate fix makes the codecs use the prototype they are given. Until then reads follow zarr.config, and in GPU mode return CuPy arrays, which numpy.asarray refuses. ArrayResult's wording must then allow device arrays read through a GPU prototype.
  • Existing, shared with Array: writing a 0-d variable-length-bytes array raises TypeError (chunk_utils.py stores the squeezed 0-d buffer as the element), and Array's integer read of such an array returns a 0-d object array holding a 0-d array.
  • Existing, shared with Array: on Zarr format 3 a numcodecs filter declared with a non-native byte order (Delta(dtype=">i4")) reads the array's data in native order once the array is reopened, so values made by of from the creating array and by open disagree. Array.__setitem__ also still stores data in the other byte order byte-swapped through such filters (fixed here for ZarrArrayIO only). fix(codecs): keep numcodecs filter and cast_value outputs in the declared dtype across byte orders #476 defines the filter byte-order contract.
  • There is no dtype (it is in metadata; whether it should return a NumPy dtype or zarr's data type is undecided), fill_value or chunk introspection (chunk_key, chunk_grid_shape) yet.
  • Sharding's coalescing sizes are not per-call options yet (they use the defaults), and ChunkNotFoundError's message still points to the global array.read_missing_chunks setting, which ZarrArrayIO does not read.
  • Whether the runner should come from the store's resource context once stores carry one; the default runner has no timeout.
  • What metadata returns once zarr-metadata's models are used.
  • The soft-deprecation note on Array._async_array and Array.async_array, pointing to AsyncZarrArrayIO.of.

🤖 Generated with Claude Code

d-v-b added 15 commits November 29, 2026 17:43
tools/compat runs seeded existing-API scenarios under this checkout and under
a baseline commit or release, and reports every observable difference.

Assisted-by: ClaudeCode:claude-opus-5-5
_ArrayIO is a value over an array's metadata, location, configuration, codec
pipeline and chunk grid that holds the routines reading and writing it:
selections, the repair of a stored document, resize and attribute updates.
Array builds one from its AsyncArray for each operation and adopts a resize
in place, so every holder of that AsyncArray sees it. An Array over a subclass
of AsyncArray keeps going through the subclass. AsyncArray's leaf methods run
on the same routines.

Assisted-by: ClaudeCode:claude-opus-5-5
AsyncArrayIO holds the routines that read and write an array; it repairs
nothing implicitly and refuses chunk writes under metadata whose stored
document needs a repair that moves chunks until store_repair has stored it.
ArrayIO runs each AsyncArrayIO operation on the event loop its SyncContext
returns. AsyncArray builds an AsyncArrayIO from its fields for each operation,
and Array goes through AsyncArray as before, so hooks on AsyncArray's methods
still see Array's reads and writes.

Assisted-by: ClaudeCode:claude-opus-5-5
AsyncArray again records a stored repair and a resize through its own
_stored_document_replaced, and writes through an AsyncArrayIO method that does
not check the repair a second time, so a subclass overriding
_store_repaired_document decides as it did before. AsyncArrayIO and ArrayIO
are unhashable on purpose, and SyncContext documents that its loop must be
running.

Assisted-by: ClaudeCode:claude-opus-5-5
…text

SyncContext.run is a Runner, a callable that runs a coroutine to completion
and returns its result. The default is zarr.core.sync.sync, which runs it on
zarr's own loop; asyncio.Runner().run runs it on the calling thread. A runner
replaces the loop callable, whose contract could not be checked (a loop that
nothing runs blocks forever).

Assisted-by: ClaudeCode:claude-opus-5-5
AsyncArrayIO.store_repair and resize each compose a private storing step with
clearing the mark. AsyncArray runs the storing step and clears the mark through
its own _stored_document_replaced, so a subclass that overrides the hook
decides whether the mark is cleared, as on main.

Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
…rest

AsyncArrayIO's constructor takes metadata, store_path and config by keyword and
derives the codec pipeline and chunk grid, which are neither constructor
parameters nor compared. Other changes from a design audit:

- update_attributes returns a new value instead of changing the attributes of
  the value (and the array) it was called on;
- get_selection and set_selection are private, since an indexer needs the
  chunk grid to build; getitem and setitem are the public reads and writes;
- resize takes delete_outside_chunks by keyword;
- ArrayIO takes its context by keyword and gains config and dtype;
- both classes have a short repr, as AsyncArray does;
- Runner and SyncContext move to zarr.core.sync, beside sync.

Assisted-by: ClaudeCode:claude-opus-5-5
An array is a value made with open (reads the metadata), from_metadata (binds
metadata, storing and checking nothing) or of (snapshots an Array or
AsyncArray). Metadata changes are values: with_shape and with_attrs return a new
value and store nothing; store_metadata stores it, erase_metadata, erase_chunk
and erase_chunks delete. Reads and writes use zarrs' vocabulary:
retrieve_array_subset, store_array_subset, retrieve_chunk and store_chunk, with
__getitem__ (and __setitem__ on ArrayIO) as sugar.

A value opened from a document whose repair moves chunks needs a repair:
storing chunks raises MetadataRepairRequiredError until store_metadata has
stored the repaired metadata. Fields are private, equality is identity, and
the classes are made only by their constructors. ArrayIO runs coroutines
through SyncContext.runner, shaped like asyncio.Runner, and as_sync/as_async
move between the two.

Assisted-by: ClaudeCode:claude-opus-5-5
… data

From the review of the reshaped API:

- attributes are deep-copied wherever a value takes them in or hands them out,
  so no dict reaches another value or the array a value was made from;
- store_array_subset and store_chunk refuse data that does not fit the region
  (ValueError) or whose values would not survive the cast (TypeError);
- every chunk method takes non-negative chunk indices, one for each dimension;
  reads and writes need them inside the chunk grid, erasing does not;
- open and from_metadata take no config: values use fixed defaults, not the
  global configuration;
- read_only is gone, the classes are final, selection, data, indices, shape
  and attrs are positional-only, and as_sync needs its context;
- docstrings say what metadata returns, what growing after a shrink reads,
  and how to write after storing a repair.

Assisted-by: ClaudeCode:claude-opus-5-5
…a plain dict

The casting check refused lossless writes (an int64 array into uint8, ints into
bool) and let lossy ones through (narrowing within a kind), and it read a
structured record as an extra dimension. Writes through ArrayIO now refuse only
data that does not broadcast to the region, which would drop values, reading a
sequence as the array's data type first; values cast as NumPy casts them, as
they do through Array.

Chunk indices refuse booleans. from_metadata accepts the plain dict that the
metadata property returns.

Assisted-by: ClaudeCode:claude-opus-5-5
Writes through ArrayIO drop leading axes of length 1 beyond the region's, as
NumPy assignment does. Chunk indices are read once, so an iterator works.
A test covers from_metadata with a read-only mapping.

Assisted-by: ClaudeCode:claude-opus-5-5
_fitted_data now returns the data broadcast to the selected region, so data
that broadcasts writes as NumPy assignment writes it whatever chunks the region
spans (it failed across chunks before, as it still does through Array). Inputs
without reshape, such as a memoryview, are read as arrays first, and a refusal
names the shape the caller passed. Chunk indices accept any iterable of ints.

Assisted-by: ClaudeCode:claude-opus-5-5
… the write

Broadcasting the data to the region before the write cast the whole region at
once (a 0-d float64 into a large float32 array allocated it all), lost
sharding's scalar fast path, and let a memoryview skip the check, since NumPy
counts memoryview as a scalar. _fitted_data now only checks: data with a shape
keeps it, a sequence is read as the array's data type, leading length-1 axes
are dropped, and data that does not broadcast is refused. The write then casts
and splits the data as it does for Array.

Assisted-by: ClaudeCode:claude-opus-5-5
Also rewrite the changelog fragment for #470 to describe the current API.

Assisted-by: ClaudeCode:claude-opus-5-5
@d-v-b d-v-b changed the title refactor(array): read and write arrays through AsyncArrayIO and a sync ArrayIO feat(array): read and write arrays as values through AsyncArrayIO and ArrayIO Nov 29, 2026
d-v-b and others added 5 commits November 29, 2026 20:20
Assisted-by: ClaudeCode:claude-opus-5-5
Reads take read_missing_chunks (a missing chunk reads as the fill value, or
raises ChunkNotFoundError for data known to be complete read over a connection
that can fail) and writes take store_empty_chunks. Neither comes from the value
or from the array it was taken from, and data reads in C order, except that a
Zarr format 2 array keeps the order its metadata declares.

Assisted-by: ClaudeCode:claude-opus-5-5
AsyncArrayIO no longer holds an ArrayConfig. Its internal reads and writes take
one as a required keyword: a public operation's, built from its own options, or
an AsyncArray's own, which AsyncArray now passes explicitly. A future operation
cannot fall back to a configuration the value happened to carry. Tests cover
store_chunk's store_empty_chunks and a default read of a missing chunk.

Assisted-by: ClaudeCode:claude-opus-5-5
Both are in the metadata, and what dtype should return (a NumPy dtype or zarr's
data type) is undecided; adding it later breaks nothing. The reprs still name
the data type, and ArrayIO's repr is AsyncArrayIO's.

Assisted-by: ClaudeCode:claude-opus-5-5
Move the interface to zarr.abc.array_io as typing protocols, so other
implementations (one built on zarrs, such as zarrista) can satisfy it
without zarr-python's internals. zarr-python's classes become
ZarrArrayIO and AsyncZarrArrayIO.

Reads return ArrayResult, anything numpy.asarray accepts; a selection of
only integers reads into a 0-d buffer of the array's data type, so byte
order, StringDType and trailing NULs survive. Writes take ArrayData:
data that exports only through DLPack is viewed as NumPy when it is in
host memory and refused otherwise; anything with __array__ is written as
Array writes it.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@d-v-b d-v-b changed the title feat(array): read and write arrays as values through AsyncArrayIO and ArrayIO feat(array): define ArrayIO and AsyncArrayIO as protocols in zarr.abc.array_io Nov 29, 2026
d-v-b and others added 7 commits November 30, 2026 15:07
The store is an implementation detail of an ArrayIO value: the constructors
take one, but neither ZarrArrayIO nor AsyncZarrArrayIO exposes it. The
protocols never had a store member; `path` stays.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A selection is now slices with a step of 1 and Ellipsis, and data has the
subset's shape. Integers are left out of the interface because
implementations differ on them: zarr-python drops an integer's axis as NumPy
does, while zarrista keeps it as a range of length 1. ZarrArrayIO refuses an
integer or other non-slice selector with TypeError and a step other than 1
with ValueError, so code that runs against it means the same thing against
any implementation. NumPy indexing stays in zarr.Array.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slice bounds mean what they mean to NumPy (negative bounds count from the
end, bounds past the end are clipped, a reversed slice is empty), which
zarr-python and zarrista already agree on; the type of a refusal's error is
not part of the interface. Tests cover the bounds, booleans, nested tuples
and steps of 0 and -1.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implementations format an array's path differently (zarr-python gives '' and
'g/a', zarrista '/' and '/g/a'), and with the store private a path is about
where a store holds the array, so it is an implementation attribute.
ZarrArrayIO and AsyncZarrArrayIO keep `path`.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ArrayData is now SupportsDLPack alone, with exactly the region's shape and the
array's data type. With Buffer in ArrayData, the same call stored different
values: b"12" written to a uint8 array was one value to zarr-python and two
raw bytes to zarrista. zarr-python also broadcast scalars and cast data types
where zarrista refuses them.

ZarrArrayIO refuses lists, scalars, byte buffers and other non-DLPack data
and other data types with TypeError, and other shapes with ValueError.
NumPy arrays of data types DLPack cannot carry (strings, records) are still
written when their data type is the array's. zarr.Array keeps broadcasting
and casting.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The data-type check compared byte order, so on Zarr format 3 (where byte
order belongs to the bytes codec) the accepted order depended on how the
value was made: ZarrArrayIO.of(array) refused native data for an array
created as ">i4", and ZarrArrayIO.open refused ">i4" data for the same
stored array. Byte order changes no value and DLPack carries only native
order, so data types now compare in native byte order. A data type NumPy
cannot read (a device tensor's) is refused with a clear TypeError.

The protocol now also says an implementation may refuse data not in C
order, and that chunks outside the chunk grid are not part of the
interface.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A chunk at the array's edge is now read and written in the chunk's full
shape, padding included, as zarrs does: retrieve_chunk returns the full
chunk with the part past the array's shape read as the fill value, and
store_chunk takes the full chunk and stores only the part inside the array.
Before, zarr-python gave and took only the part inside, so the same call
returned different shapes from ZarrArrayIO and zarrista (for sharded and
transposed arrays too). What the padding of a stored chunk reads as is not
part of the interface.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d-v-b and others added 4 commits November 30, 2026 16:00
The same ArrayIO calls on the same stored array, through ZarrArrayIO and
zarrista, must read the same values, subsets and chunks, store the same
chunk keys, and refuse the same data: 7 data types across regular,
big-endian, transposed and sharded layouts, with whole, partial, clipped and
empty writes, a full edge chunk, an all-fill chunk and an erase. zarrista
0.1.0 joins the test dependency group on platforms it has wheels for; the
test is skipped where it is absent.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Data that differs from the array's data type only in byte order reached
the codecs unconverted (the write casts only when the dtype name differs),
and numcodecs filters such as Delta read its bytes as the array's data
type, so every value was stored byte-swapped. It is now converted in
_exact_data. The native-order comparison also covers subarray fields, and
an edge chunk of a Zarr format 2 array reads in the order its metadata
declares, as other chunks do. The interface now says whether data past the
array's edge counts toward an all-fill chunk is not part of it.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zarrista moves to its own zarrista-tests dependency group, installed by the
optional rows of the test matrix only: in the test group it made min_deps
unresolvable (zarrista needs typing_extensions>=4.16) and it cannot run on
NumPy 2.0, so the module also skips below NumPy 2.1.

The comparison now has each implementation read the other's store, so a
codec bug that is wrong the same way on write and read is caught; compares
bytes, so -0.0 and NaN payloads are not equated; and covers all-fill chunk
and subset writes with and without store_empty_chunks.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plain `uv sync` installs the dev group, which lost zarrista when it moved
to its own group, so tests/test_array_io_zarrista.py was skipped locally
without notice.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant