zarr.testing.buffer#

Classes#

NDBufferUsingTestNDArrayLike

Example of a custom NDBuffer that handles MyNDArrayLike

StoreExpectingTestBuffer

Example of a custom Store that expect MyBuffer for all its non-metadata

TestBuffer

Example of a custom Buffer that handles ArrayLike

Module Contents#

class zarr.testing.buffer.NDBufferUsingTestNDArrayLike(array: zarr.core.buffer.core.NDArrayLike)[source]#

Bases: zarr.core.buffer.cpu.NDBuffer

Example of a custom NDBuffer that handles MyNDArrayLike

classmethod create(
*,
shape: collections.abc.Iterable[int],
dtype: numpy.typing.DTypeLike,
order: Literal['C', 'F'] = 'C',
fill_value: Any | None = None,
) Self[source]#

Overwrite NDBuffer.create to create an TestNDArrayLike instance

class zarr.testing.buffer.StoreExpectingTestBuffer(
store_dict: collections.abc.MutableMapping[str, zarr.core.buffer.Buffer] | None = None,
*,
read_only: bool = False,
)[source]#

Bases: zarr.storage.MemoryStore

Example of a custom Store that expect MyBuffer for all its non-metadata

We assume that keys containing “json” is metadata

async get(
key: str,
prototype: zarr.core.buffer.BufferPrototype,
byte_range: tuple[int, int | None] | None = None,
) zarr.core.buffer.Buffer | None[source]#

Retrieve the value associated with a given key.

Parameters:
keystr
prototypeBufferPrototype

The prototype of the output buffer. Stores may support a default buffer prototype.

byte_rangeByteRequest, optional

ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header.

Returns:
Buffer
async set(
key: str,
value: zarr.core.buffer.Buffer,
byte_range: tuple[int, int] | None = None,
) None[source]#

Store a (key, value) pair.

Parameters:
keystr
valueBuffer
class zarr.testing.buffer.TestBuffer(array_like: zarr.core.buffer.core.ArrayLike)[source]#

Bases: zarr.core.buffer.cpu.Buffer

Example of a custom Buffer that handles ArrayLike