zarr.testing.stateful#

Attributes#

Classes#

SyncStoreWrapper

ZarrHierarchyStateMachine

This state machine models operations that modify a zarr store's

ZarrStoreStateMachine

Functions#

split_prefix_name(→ tuple[str, str])

Module Contents#

class zarr.testing.stateful.SyncStoreWrapper(store: zarr.abc.store.Store)[source]#

Bases: zarr.core.sync.SyncMixin

clear() None[source]#
delete(path: str) None[source]#
exists(key: str) bool[source]#
get(
key: str,
prototype: zarr.core.buffer.BufferPrototype,
) zarr.core.buffer.Buffer | None[source]#
get_partial_values(
key_ranges: list[Any],
prototype: zarr.core.buffer.BufferPrototype,
) list[zarr.core.buffer.Buffer | None][source]#
is_empty(prefix: str) bool[source]#
list() list[str][source]#
abstract list_dir(prefix: str) None[source]#
abstract list_prefix(prefix: str) None[source]#
set(key: str, data_buffer: zarr.core.buffer.Buffer) None[source]#
abstract set_partial_values(key_start_values: Any) None[source]#
property read_only: bool[source]#
store[source]#
property supports_deletes: bool[source]#
property supports_listing: bool[source]#
property supports_partial_writes: bool[source]#
property supports_writes: bool[source]#
class zarr.testing.stateful.ZarrHierarchyStateMachine(store: zarr.abc.store.Store)[source]#

Bases: zarr.core.sync.SyncMixin, hypothesis.stateful.RuleBasedStateMachine

This state machine models operations that modify a zarr store’s hierarchy. That is, user actions that modify arrays/groups as well as list operations. It is intended to be used by external stores, and compares their results to a MemoryStore that is assumed to be perfect.

add_array(
data: hypothesis.strategies.DataObject,
name: str,
array_and_chunks: tuple[numpy.ndarray[Any, Any], tuple[int, Ellipsis]],
) None[source]#
add_group(name: str, data: hypothesis.strategies.DataObject) None[source]#
can_add(path: str) bool[source]#
check_list_prefix_from_root() None[source]#
delete_array_using_del(data: hypothesis.strategies.DataObject) None[source]#
delete_group_using_del(data: hypothesis.strategies.DataObject) None[source]#
init_store() None[source]#
all_arrays: set[str][source]#
all_groups: set[str][source]#
model[source]#
store[source]#
class zarr.testing.stateful.ZarrStoreStateMachine(store: zarr.abc.store.Store)[source]#

Bases: hypothesis.stateful.RuleBasedStateMachine

” Zarr store state machine

This is a subclass of a Hypothesis RuleBasedStateMachine. It is testing a framework to ensure that the state of a Zarr store matches an expected state after a set of random operations. It contains a store (currently, a Zarr MemoryStore) and a model, a simplified version of a zarr store (in this case, a dict). It also contains rules which represent actions that can be applied to a zarr store. Rules apply an action to both the store and the model, and invariants assert that the state of the model is equal to the state of the store. Hypothesis then generates sequences of rules, running invariants after each rule. It raises an error if a sequence produces discontinuity between state of the model and state of the store (ie. an invariant is violated). https://hypothesis.readthedocs.io/en/latest/stateful.html

check_num_zarr_keys_equal() None[source]#
check_paths_equal() None[source]#
check_vals_equal() None[source]#
check_zarr_keys() None[source]#
clear() None[source]#
delete(data: hypothesis.strategies.DataObject) None[source]#
exists(key: str) None[source]#
get(key: str, data: hypothesis.strategies.DataObject) None[source]#
get_invalid_zarr_keys(key: str, data: hypothesis.strategies.DataObject) None[source]#
get_partial_values(data: hypothesis.strategies.DataObject) None[source]#
init_store() None[source]#
is_empty() None[source]#
set(key: str, data: hypothesis.strategies.DataObject) None[source]#
model: dict[str, zarr.core.buffer.Buffer][source]#
prototype[source]#
store[source]#
zarr.testing.stateful.split_prefix_name(path: str) tuple[str, str][source]#
zarr.testing.stateful.MAX_BINARY_SIZE = 100[source]#