Skip to content

abczarr.metadata.v2.dtypes

Classes

DType

A Zarr v2 data type: a numpy dtype string, or a structured field list.

Constructing DType(value) returns a ScalarDType for a plain dtype, such as "<f8", or a StructDType for a structured one, whichever value describes.

Parameters:

Name Type Description Default
value dtype - like

A numpy dtype, a dtype string, or a structured field list, to convert to the matching DType subclass.

required

Attributes

numpy property
numpy: dtype

The equivalent numpy.dtype.

Methods:

__new__
__new__(value: Any) -> Self
to_version
to_version(version: int) -> Any

Convert this data type to another Zarr version.

Parameters:

Name Type Description Default
version int

The target Zarr format version: 1, 2 or 3.

required

Returns:

Type Description
DType

This data type unchanged for version 1 or 2, since v1 and v2 share the same dtype model, or the equivalent v3 data type for version 3.

Raises:

Type Description
ValueError

If version is not 1, 2 or 3.

ScalarDType

Bases: str, DType

A Zarr v2 scalar data type: a numpy dtype string, for example "<f8".

A ScalarDType encodes the byte order, kind and item size the way .zarray's dtype field does.

Parameters:

Name Type Description Default
value str

A numpy dtype string in Zarr v2's encoding, such as "<f8".

required

Methods:

__new__
__new__(value: str) -> Self

StructDType

Bases: list, DType

A Zarr v2 structured data type: an ordered list of (name, dtype) fields.

A StructDType mirrors numpy's structured dtype list form and is immutable. Every list-mutation method raises TypeError instead of changing the value after construction.

Parameters:

Name Type Description Default
value iterable of tuple

The (name, dtype) pairs the structured type is built from, in field order.

required

Attributes

__setitem__ class-attribute instance-attribute
__setitem__ = wraps(list.__setitem__)(_immutable)
__delitem__ class-attribute instance-attribute
__delitem__ = wraps(list.__delitem__)(_immutable)
__iadd__ class-attribute instance-attribute
__iadd__ = wraps(list.__iadd__)(_immutable)
__imul__ class-attribute instance-attribute
__imul__ = wraps(list.__imul__)(_immutable)
append class-attribute instance-attribute
append = wraps(list.append)(_immutable)
extend class-attribute instance-attribute
extend = wraps(list.extend)(_immutable)
pop class-attribute instance-attribute
pop = wraps(list.pop)(_immutable)
clear class-attribute instance-attribute
clear = wraps(list.clear)(_immutable)
insert class-attribute instance-attribute
insert = wraps(list.insert)(_immutable)
remove class-attribute instance-attribute
remove = wraps(list.remove)(_immutable)
reverse class-attribute instance-attribute
reverse = wraps(list.reverse)(_immutable)

Methods:

__new__
__new__(value: Iterable[tuple[str, str]]) -> Self