zarr.testing.strategies#

Attributes#

Functions#

array_metadata(...)

arrays(, array_names, arrays, attrs, zarr_formats)

basic_indices(→ Any)

Basic indices without unsupported negative slices.

chunk_shapes(→ tuple[int, Ellipsis])

clear_store(→ zarr.abc.store.Store)

dimension_names(→ list[None | str] | None)

end_slices(→ Any)

A strategy that slices ranges that include the last chunk.

is_negative_slice(→ bool)

key_ranges(...)

Function to generate key_ranges strategy for get_partial_values()

keys(→ Any)

np_array_and_chunks(→ tuple[numpy.ndarray, tuple[int, ...)

A hypothesis strategy to generate small sized random arrays.

numpy_arrays(→ Any)

Generate numpy arrays that can be saved in the provided Zarr format.

orthogonal_indices(→ tuple[tuple[numpy.ndarray[Any, ...)

Strategy that returns

paths(→ Any)

safe_unicode_for_dtype(...)

Generate UTF-8-safe text constrained to max_len of dtype.

shard_shapes(→ tuple[int, Ellipsis])

simple_arrays(→ Any)

v2_dtypes(...)

v3_dtypes(...)

Module Contents#

zarr.testing.strategies.array_metadata(
*,
array_shapes: hypothesis.strategies.SearchStrategy[tuple[int, Ellipsis]] = npst.array_shapes,
zarr_formats: hypothesis.strategies.SearchStrategy[Literal[2, 3]] = zarr_formats,
attributes: hypothesis.strategies.SearchStrategy[dict[str, Any]] = attrs,
) zarr.core.metadata.ArrayV2Metadata | zarr.core.metadata.ArrayV3Metadata[source]#
zarr.testing.strategies.arrays(
*,
shapes: hypothesis.strategies.SearchStrategy[tuple[int, Ellipsis]] = array_shapes,
compressors: hypothesis.strategies.SearchStrategy = compressors,
stores: hypothesis.strategies.SearchStrategy[zarr.storage.StoreLike] = stores,
paths: hypothesis.strategies.SearchStrategy[str | None] = paths(),
array_names: hypothesis.strategies.SearchStrategy = array_names,
arrays: hypothesis.strategies.SearchStrategy | None = None,
attrs: hypothesis.strategies.SearchStrategy = attrs,
zarr_formats: hypothesis.strategies.SearchStrategy = zarr_formats,
) zarr.core.array.Array[source]#
zarr.testing.strategies.basic_indices(*, shape: tuple[int], **kwargs: Any) Any[source]#

Basic indices without unsupported negative slices.

zarr.testing.strategies.chunk_shapes(*, shape: tuple[int, Ellipsis]) tuple[int, Ellipsis][source]#
zarr.testing.strategies.clear_store(x: zarr.abc.store.Store) zarr.abc.store.Store[source]#
zarr.testing.strategies.dimension_names(*, ndim: int | None = None) list[None | str] | None[source]#
zarr.testing.strategies.end_slices(*, shape: tuple[int]) Any[source]#

A strategy that slices ranges that include the last chunk. This is intended to stress-test handling of a possibly smaller last chunk.

zarr.testing.strategies.is_negative_slice(idx: Any) bool[source]#
zarr.testing.strategies.key_ranges(
keys: hypothesis.strategies.SearchStrategy = node_names,
max_size: int = sys.maxsize,
) hypothesis.strategies.SearchStrategy[list[int]][source]#

Function to generate key_ranges strategy for get_partial_values() returns list strategy w/ form:

[(key, (range_start, range_end)),
 (key, (range_start, range_end)),...]
zarr.testing.strategies.keys(*, max_num_nodes: int | None = None) Any[source]#
zarr.testing.strategies.np_array_and_chunks(
*,
arrays: hypothesis.strategies.SearchStrategy[numpy.ndarray] = numpy_arrays,
) tuple[numpy.ndarray, tuple[int, Ellipsis]][source]#

A hypothesis strategy to generate small sized random arrays.

Returns: a tuple of the array and a suitable random chunking for it.

zarr.testing.strategies.numpy_arrays(
*,
shapes: hypothesis.strategies.SearchStrategy[tuple[int, Ellipsis]] = array_shapes,
dtype: numpy.dtype[Any] | None = None,
zarr_formats: hypothesis.strategies.SearchStrategy[zarr.core.common.ZarrFormat] | None = zarr_formats,
) Any[source]#

Generate numpy arrays that can be saved in the provided Zarr format.

zarr.testing.strategies.orthogonal_indices(
*,
shape: tuple[int],
) tuple[tuple[numpy.ndarray[Any, Any], Ellipsis], tuple[numpy.ndarray[Any, Any], Ellipsis]][source]#

Strategy that returns (1) a tuple of integer arrays used for orthogonal indexing of Zarr arrays. (2) an tuple of integer arrays that can be used for equivalent indexing of numpy arrays

zarr.testing.strategies.paths(*, max_num_nodes: int | None = None) Any[source]#
zarr.testing.strategies.safe_unicode_for_dtype(
dtype: numpy.dtype[numpy.str_],
) hypothesis.strategies.SearchStrategy[str][source]#

Generate UTF-8-safe text constrained to max_len of dtype.

zarr.testing.strategies.shard_shapes(
*,
shape: tuple[int, Ellipsis],
chunk_shape: tuple[int, Ellipsis],
) tuple[int, Ellipsis][source]#
zarr.testing.strategies.simple_arrays(
*,
shapes: hypothesis.strategies.SearchStrategy[tuple[int, Ellipsis]] = array_shapes,
) Any[source]#
zarr.testing.strategies.v2_dtypes() hypothesis.strategies.SearchStrategy[numpy.dtype][source]#
zarr.testing.strategies.v3_dtypes() hypothesis.strategies.SearchStrategy[numpy.dtype][source]#
zarr.testing.strategies.array_names[source]#
zarr.testing.strategies.array_shapes[source]#
zarr.testing.strategies.attrs[source]#
zarr.testing.strategies.compressors[source]#
zarr.testing.strategies.node_names[source]#
zarr.testing.strategies.short_node_names[source]#
zarr.testing.strategies.stores[source]#
zarr.testing.strategies.zarr_formats: hypothesis.strategies.SearchStrategy[zarr.core.common.ZarrFormat][source]#
zarr.testing.strategies.zarr_key_chars[source]#