Zarr¶
Interface to zarr arrays
- class ZarrArrayPath(file: Path | str, path: str | None = None)[source]¶
Map to an array within a zarr store.
See
zarr.open()- classmethod from_iterable(spec: Sequence) ZarrArrayPath[source]¶
Construct a
ZarrArrayPathspecifier from an iterable, rather than kwargs
- pydantic model ZarrJsonDict[source]¶
Round-trip Json-able version of a Zarr Array
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Fields:
- to_array_input() Array | ZarrArrayPath[source]¶
Construct a ZarrArrayPath if file and path are present, otherwise a ZarrArray
- class ZarrInterface(shape: Tuple[int, ...] | Any = typing.Any, dtype: str | type | Any | generic = typing.Any)[source]¶
Interface to in-memory or on-disk zarr arrays
- json_model¶
alias of
ZarrJsonDict
- classmethod check(array: Any) bool[source]¶
Check if array is in-memory zarr array, a path to a zarr array, or a
ZarrArrayPath
- before_validation(array: Array | str | Path | ZarrArrayPath | Sequence) Array[source]¶
Ensure that the zarr array is opened
- get_dtype(array: Array) str | type | Any | generic[source]¶
Override base dtype getter to handle zarr’s string-as-object encoding.
- classmethod to_json(array: Array | str | Path | ZarrArrayPath | Sequence, info: SerializationInfo | None = None) list | ZarrJsonDict[source]¶
Dump a Zarr Array to JSON
If
info.round_trip == False, dump the array as a list of lists. This may be a memory-intensive operation.Otherwise, dump the metadata for an array from
zarr.core.Array.info_items()plus thezarr.core.Array.hexdigest()as aZarrJsonDictIf either the
dump_arrayvalue in the context dictionary isTrueor the zarr array is an in-memory array, dump the array as well (since without a persistent array it would be impossible to roundtrip and dumping to JSON would be meaningless)Passing
`dump_array': Trueto the serializationcontextlooks like this:model.model_dump_json(context={'zarr_dump_array': True})