Skip to content

Array creation

zarrista.ArrayBuilder

A chained, immutable builder for creating Zarr arrays.

Every setter returns a new ArrayBuilder and leaves the receiver unchanged, so a builder can be safely shared and specialized. Seed one with the constructor or ArrayBuilder.like, chain setters to configure it, then materialize the array with create / create_async, or produce only its metadata with create_metadata.

__init__

__init__(chunk_grid: ChunkGrid, dtype: DataType, fill_value: FillValue) -> None

Create a builder from a chunk grid, data type, and fill value.

attrs

attrs(attrs: Mapping[str, JSONValue]) -> ArrayBuilder

Return a new builder with the given user attributes set.

chunk_grid

chunk_grid(chunk_grid: ChunkGrid) -> ArrayBuilder

Return a new builder with the chunk grid set.

This may also change the array shape, since the grid carries one.

chunk_key_encoding

chunk_key_encoding(chunk_key_encoding: ChunkKeyEncoding) -> ArrayBuilder

Return a new builder with the chunk key encoding set.

compressors

compressors(compressors: Sequence[BytesToBytesCodec]) -> ArrayBuilder

Return a new builder with the bytes-to-bytes codecs ("compressors") set.

create

create(store: FilesystemStore | MemoryStore, path: str) -> Array

Build the array in store at path and return it.

create_async async

create_async(store: AsyncStore, path: str) -> AsyncArray

Build the array in an async store at path and return it.

create_metadata

create_metadata() -> ArrayMetadataV3

Build the array's Zarr v3 metadata without touching a store.

data_type

data_type(data_type: DataType) -> ArrayBuilder

Return a new builder with the data type set.

dimension_names

dimension_names(dimension_names: Sequence[str | None] | None) -> ArrayBuilder

Return a new builder with the dimension names set (or cleared).

filters

filters(filters: Sequence[ArrayToArrayCodec]) -> ArrayBuilder

Return a new builder with the array-to-array codecs ("filters") set.

like staticmethod

like(array: Array | AsyncArray) -> ArrayBuilder

Create a builder copying the configuration of an existing array.

serializer

serializer(serializer: ArrayToBytesCodec) -> ArrayBuilder

Return a new builder with the array-to-bytes codec ("serializer") set.

Sharding is itself an array-to-bytes codec, so a sharding serializer is passed here too.

shape

shape(shape: Sequence[int]) -> ArrayBuilder

Return a new builder with the array shape set.

subchunk_shape

subchunk_shape(subchunk_shape: Sequence[int] | None) -> ArrayBuilder

Return a new builder with the inner (subchunk) shape, enabling sharding.

zarrista.ArrayBytes

Chunk bytes as input or output from a codec.

Wraps a data buffer, plus optional element byte offsets (for variable-length data) and an optional validity mask.

bytes property

bytes: Buffer

The underlying element bytes (the data buffer for optional bytes).

mask property

mask: Buffer | None

The validity mask (1 byte per element), or None if not optional.

offsets property

offsets: list[int] | None

Element byte offsets, or None for fixed-length data.

__init__

__init__(
    bytes: Buffer,
    *,
    mask: Buffer | None = None,
    offsets: list[int] | None = None
) -> None

Construct from a data buffer, with an optional mask and offsets.