zarr_metadata.v3.data_type
zarr_metadata.v3.data_type ¶
Zarr v3 data type spec types.
Each v3 data type has its own submodule:
- Core primitives:
bool,int8/16/32/64,uint8/16/32/64,float16/32/64,complex64/128,raw(forr<N>) - zarr-extensions:
bytes,string,numpy_datetime64,numpy_timedelta64,struct
The two canonical types per dtype are re-exported here:
<X>DataTypeName-- the literal type of the dtype'sdata_typestring (or, for named-config dtypes, the literal value of theirnamefield)<X>FillValue-- the permitted JSON shape of thefill_valuefield
Named-config dtypes (numpy_datetime64, numpy_timedelta64, struct) also
expose their envelope TypedDict here. For configuration TypedDicts, branded
HexFloat<N> / Base64Bytes types, and the corresponding validator
functions, import directly from the leaf submodule.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
zarr_metadata.v3.data_type.bool ¶
Zarr v3 bool data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
BOOL_DATA_TYPE_NAME
module-attribute
¶
BOOL_DATA_TYPE_NAME: Final = 'bool'
The data_type value for the bool type.
BoolDataTypeName
module-attribute
¶
BoolDataTypeName = Literal['bool']
Literal type of the data_type field for bool.
BoolFillValue
module-attribute
¶
BoolFillValue = bool
Permitted JSON shape of the fill_value field for bool: a JSON boolean.
__all__
module-attribute
¶
BoolDataType
dataclass
¶
Bases: DataTypeEntity
The bool data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/bool.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = BOOL_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.int8 ¶
Zarr v3 int8 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
INT8_DATA_TYPE_NAME
module-attribute
¶
INT8_DATA_TYPE_NAME: Final = 'int8'
The data_type value for the int8 type.
Int8DataTypeName
module-attribute
¶
Int8DataTypeName = Literal['int8']
Literal type of the data_type field for int8.
Int8FillValue
module-attribute
¶
Int8FillValue = int
Permitted JSON shape of the fill_value field for int8: a JSON integer in [-128, 127].
__all__
module-attribute
¶
Int8DataType
dataclass
¶
Bases: IntegerDataType
The int8 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/int8.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = INT8_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.int16 ¶
Zarr v3 int16 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
INT16_DATA_TYPE_NAME
module-attribute
¶
INT16_DATA_TYPE_NAME: Final = 'int16'
The data_type value for the int16 type.
Int16DataTypeName
module-attribute
¶
Int16DataTypeName = Literal['int16']
Literal type of the data_type field for int16.
Int16FillValue
module-attribute
¶
Int16FillValue = int
Permitted JSON shape of the fill_value field for int16: a JSON integer in [-32768, 32767].
__all__
module-attribute
¶
Int16DataType
dataclass
¶
Bases: IntegerDataType
The int16 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/int16.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = INT16_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.int32 ¶
Zarr v3 int32 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
INT32_DATA_TYPE_NAME
module-attribute
¶
INT32_DATA_TYPE_NAME: Final = 'int32'
The data_type value for the int32 type.
Int32DataTypeName
module-attribute
¶
Int32DataTypeName = Literal['int32']
Literal type of the data_type field for int32.
Int32FillValue
module-attribute
¶
Int32FillValue = int
Permitted JSON shape of the fill_value field for int32: a JSON integer in [-231, 231 - 1].
__all__
module-attribute
¶
Int32DataType
dataclass
¶
Bases: IntegerDataType
The int32 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/int32.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = INT32_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.int64 ¶
Zarr v3 int64 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
INT64_DATA_TYPE_NAME
module-attribute
¶
INT64_DATA_TYPE_NAME: Final = 'int64'
The data_type value for the int64 type.
Int64DataTypeName
module-attribute
¶
Int64DataTypeName = Literal['int64']
Literal type of the data_type field for int64.
Int64FillValue
module-attribute
¶
Int64FillValue = int
Permitted JSON shape of the fill_value field for int64: a JSON integer in [-263, 263 - 1].
__all__
module-attribute
¶
Int64DataType
dataclass
¶
Bases: IntegerDataType
The int64 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/int64.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = INT64_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.uint8 ¶
Zarr v3 uint8 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
UINT8_DATA_TYPE_NAME
module-attribute
¶
UINT8_DATA_TYPE_NAME: Final = 'uint8'
The data_type value for the uint8 type.
Uint8DataTypeName
module-attribute
¶
Uint8DataTypeName = Literal['uint8']
Literal type of the data_type field for uint8.
Uint8FillValue
module-attribute
¶
Uint8FillValue = int
Permitted JSON shape of the fill_value field for uint8: a JSON integer in [0, 255].
__all__
module-attribute
¶
Uint8DataType
dataclass
¶
Bases: IntegerDataType
The uint8 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/uint8.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = UINT8_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.uint16 ¶
Zarr v3 uint16 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
UINT16_DATA_TYPE_NAME
module-attribute
¶
UINT16_DATA_TYPE_NAME: Final = 'uint16'
The data_type value for the uint16 type.
Uint16DataTypeName
module-attribute
¶
Uint16DataTypeName = Literal['uint16']
Literal type of the data_type field for uint16.
Uint16FillValue
module-attribute
¶
Uint16FillValue = int
Permitted JSON shape of the fill_value field for uint16: a JSON integer in [0, 65535].
__all__
module-attribute
¶
Uint16DataType
dataclass
¶
Bases: IntegerDataType
The uint16 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/uint16.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = UINT16_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.uint32 ¶
Zarr v3 uint32 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
UINT32_DATA_TYPE_NAME
module-attribute
¶
UINT32_DATA_TYPE_NAME: Final = 'uint32'
The data_type value for the uint32 type.
Uint32DataTypeName
module-attribute
¶
Uint32DataTypeName = Literal['uint32']
Literal type of the data_type field for uint32.
Uint32FillValue
module-attribute
¶
Uint32FillValue = int
Permitted JSON shape of the fill_value field for uint32: a JSON integer in [0, 2**32 - 1].
__all__
module-attribute
¶
Uint32DataType
dataclass
¶
Bases: IntegerDataType
The uint32 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/uint32.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = UINT32_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.uint64 ¶
Zarr v3 uint64 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
UINT64_DATA_TYPE_NAME
module-attribute
¶
UINT64_DATA_TYPE_NAME: Final = 'uint64'
The data_type value for the uint64 type.
Uint64DataTypeName
module-attribute
¶
Uint64DataTypeName = Literal['uint64']
Literal type of the data_type field for uint64.
Uint64FillValue
module-attribute
¶
Uint64FillValue = int
Permitted JSON shape of the fill_value field for uint64: a JSON integer in [0, 2**64 - 1].
__all__
module-attribute
¶
Uint64DataType
dataclass
¶
Bases: IntegerDataType
The uint64 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/uint64.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = UINT64_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = True
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.float16 ¶
Zarr v3 float16 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
CANONICAL_NAN_HEX_FLOAT16
module-attribute
¶
CANONICAL_NAN_HEX_FLOAT16: Final = '0x7e00'
Canonical hex form of the float16 NaN sentinel "NaN".
Per spec (https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L72-L74) the named "NaN" sentinel denotes the float with sign=0, the
most significant mantissa bit set, and all other mantissa bits zero
(the IEEE 754 default quiet NaN). Other NaN bit patterns must be
encoded with the explicit hex-string form.
CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT16
module-attribute
¶
CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT16: Final = '0xfc00'
Canonical hex form of the float16 "-Infinity" sentinel.
CANONICAL_POSITIVE_INFINITY_HEX_FLOAT16
module-attribute
¶
CANONICAL_POSITIVE_INFINITY_HEX_FLOAT16: Final = '0x7c00'
Canonical hex form of the float16 "Infinity" sentinel.
FLOAT16_DATA_TYPE_NAME
module-attribute
¶
FLOAT16_DATA_TYPE_NAME: Final = 'float16'
The data_type value for the float16 type.
Float16DataTypeName
module-attribute
¶
Float16DataTypeName = Literal['float16']
Literal type of the data_type field for float16.
Float16FillValue
module-attribute
¶
Float16FillValue = (
float | int | Float16SpecialFillValue | HexFloat16
)
Permitted JSON shape of the fill_value field for float16.
Either a JSON number, one of the named non-finite sentinels ("NaN",
"Infinity", "-Infinity"), or a HexFloat16 (0xYYYY string encoding
the unsigned-integer representation of the IEEE 754 value).
Float16SpecialFillValue
module-attribute
¶
Float16SpecialFillValue = Literal[
"NaN", "Infinity", "-Infinity"
]
Named non-finite fill values permitted by the spec for IEEE 754 floats.
https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L63-L79
HexFloat16
module-attribute
¶
A 6-character hex string (0x + 4 hex digits) encoding the
unsigned-integer representation of a float16.
__all__
module-attribute
¶
__all__ = [
"CANONICAL_NAN_HEX_FLOAT16",
"CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT16",
"CANONICAL_POSITIVE_INFINITY_HEX_FLOAT16",
"FLOAT16_DATA_TYPE_NAME",
"Float16DataType",
"Float16DataTypeName",
"Float16FillValue",
"Float16SpecialFillValue",
"HexFloat16",
"hex_float16",
]
Float16DataType
dataclass
¶
Bases: FloatDataType
The float16 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/float16.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = FLOAT16_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
largest
class-attribute
¶
largest: float | None = 65504.0
The largest finite magnitude this width holds, or None for float64.
None because a Python float is a float64, so no literal that reaches here can exceed it.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
hex_float16 ¶
hex_float16(value: str) -> HexFloat16
Validate value as a HexFloat16 and brand it.
Raises ValueError if value is not exactly 0x followed by 4 hex
digits.
Source code in src/zarr_metadata/v3/data_type/float16.py
zarr_metadata.v3.data_type.float32 ¶
Zarr v3 float32 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
CANONICAL_NAN_HEX_FLOAT32
module-attribute
¶
CANONICAL_NAN_HEX_FLOAT32: Final = '0x7fc00000'
Canonical hex form of the float32 NaN sentinel "NaN".
Per spec (https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L72-L74) the named "NaN" sentinel denotes the float with sign=0, the
most significant mantissa bit set, and all other mantissa bits zero
(the IEEE 754 default quiet NaN). Other NaN bit patterns must be
encoded with the explicit hex-string form.
CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT32
module-attribute
¶
CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT32: Final = (
"0xff800000"
)
Canonical hex form of the float32 "-Infinity" sentinel.
CANONICAL_POSITIVE_INFINITY_HEX_FLOAT32
module-attribute
¶
CANONICAL_POSITIVE_INFINITY_HEX_FLOAT32: Final = (
"0x7f800000"
)
Canonical hex form of the float32 "Infinity" sentinel.
FLOAT32_DATA_TYPE_NAME
module-attribute
¶
FLOAT32_DATA_TYPE_NAME: Final = 'float32'
The data_type value for the float32 type.
Float32DataTypeName
module-attribute
¶
Float32DataTypeName = Literal['float32']
Literal type of the data_type field for float32.
Float32FillValue
module-attribute
¶
Float32FillValue = (
float | int | Float32SpecialFillValue | HexFloat32
)
Permitted JSON shape of the fill_value field for float32.
Either a JSON number, one of the named non-finite sentinels ("NaN",
"Infinity", "-Infinity"), or a HexFloat32 (0xYYYYYYYY string
encoding the unsigned-integer representation of the IEEE 754 value).
Float32SpecialFillValue
module-attribute
¶
Float32SpecialFillValue = Literal[
"NaN", "Infinity", "-Infinity"
]
Named non-finite fill values permitted by the spec for IEEE 754 floats.
https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L63-L79
HexFloat32
module-attribute
¶
A 10-character hex string (0x + 8 hex digits) encoding the
unsigned-integer representation of a float32.
__all__
module-attribute
¶
__all__ = [
"CANONICAL_NAN_HEX_FLOAT32",
"CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT32",
"CANONICAL_POSITIVE_INFINITY_HEX_FLOAT32",
"FLOAT32_DATA_TYPE_NAME",
"Float32DataType",
"Float32DataTypeName",
"Float32FillValue",
"Float32SpecialFillValue",
"HexFloat32",
"hex_float32",
]
Float32DataType
dataclass
¶
Bases: FloatDataType
The float32 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/float32.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = FLOAT32_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
largest
class-attribute
¶
largest: float | None = 3.4028235e+38
The largest finite magnitude this width holds, or None for float64.
None because a Python float is a float64, so no literal that reaches here can exceed it.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
hex_float32 ¶
hex_float32(value: str) -> HexFloat32
Validate value as a HexFloat32 and brand it.
Raises ValueError if value is not exactly 0x followed by 8 hex
digits.
Source code in src/zarr_metadata/v3/data_type/float32.py
zarr_metadata.v3.data_type.float64 ¶
Zarr v3 float64 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
CANONICAL_NAN_HEX_FLOAT64
module-attribute
¶
CANONICAL_NAN_HEX_FLOAT64: Final = '0x7ff8000000000000'
Canonical hex form of the float64 NaN sentinel "NaN".
Per spec (https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L72-L74) the named "NaN" sentinel denotes the float with sign=0, the
most significant mantissa bit set, and all other mantissa bits zero
(the IEEE 754 default quiet NaN). Other NaN bit patterns must be
encoded with the explicit hex-string form.
CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT64
module-attribute
¶
CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT64: Final = (
"0xfff0000000000000"
)
Canonical hex form of the float64 "-Infinity" sentinel.
CANONICAL_POSITIVE_INFINITY_HEX_FLOAT64
module-attribute
¶
CANONICAL_POSITIVE_INFINITY_HEX_FLOAT64: Final = (
"0x7ff0000000000000"
)
Canonical hex form of the float64 "Infinity" sentinel.
FLOAT64_DATA_TYPE_NAME
module-attribute
¶
FLOAT64_DATA_TYPE_NAME: Final = 'float64'
The data_type value for the float64 type.
Float64DataTypeName
module-attribute
¶
Float64DataTypeName = Literal['float64']
Literal type of the data_type field for float64.
Float64FillValue
module-attribute
¶
Float64FillValue = (
float | int | Float64SpecialFillValue | HexFloat64
)
Permitted JSON shape of the fill_value field for float64.
Either a JSON number, one of the named non-finite sentinels ("NaN",
"Infinity", "-Infinity"), or a HexFloat64 (0xYYYYYYYYYYYYYYYY
string encoding the unsigned-integer representation of the IEEE 754
value).
Float64SpecialFillValue
module-attribute
¶
Float64SpecialFillValue = Literal[
"NaN", "Infinity", "-Infinity"
]
Named non-finite fill values permitted by the spec for IEEE 754 floats.
https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L63-L79
HexFloat64
module-attribute
¶
An 18-character hex string (0x + 16 hex digits) encoding the
unsigned-integer representation of a float64.
__all__
module-attribute
¶
__all__ = [
"CANONICAL_NAN_HEX_FLOAT64",
"CANONICAL_NEGATIVE_INFINITY_HEX_FLOAT64",
"CANONICAL_POSITIVE_INFINITY_HEX_FLOAT64",
"FLOAT64_DATA_TYPE_NAME",
"Float64DataType",
"Float64DataTypeName",
"Float64FillValue",
"Float64SpecialFillValue",
"HexFloat64",
"hex_float64",
]
Float64DataType
dataclass
¶
Bases: FloatDataType
The float64 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/float64.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = FLOAT64_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
largest
class-attribute
¶
largest: float | None = None
The largest finite magnitude this width holds, or None for float64.
None because a Python float is a float64, so no literal that reaches here can exceed it.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
hex_float64 ¶
hex_float64(value: str) -> HexFloat64
Validate value as a HexFloat64 and brand it.
Raises ValueError if value is not exactly 0x followed by 16 hex
digits.
Source code in src/zarr_metadata/v3/data_type/float64.py
zarr_metadata.v3.data_type.complex64 ¶
Zarr v3 complex64 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
COMPLEX64_DATA_TYPE_NAME
module-attribute
¶
COMPLEX64_DATA_TYPE_NAME: Final = 'complex64'
The data_type value for the complex64 type.
Complex64Component
module-attribute
¶
Complex64Component = Float32FillValue
One real or imaginary component of a complex64 fill value.
Same shape as a float32 fill value: a JSON number, a named sentinel,
or a HexFloat32 string.
Complex64DataTypeName
module-attribute
¶
Complex64DataTypeName = Literal['complex64']
Literal type of the data_type field for complex64.
Complex64FillValue
module-attribute
¶
Complex64FillValue = tuple[
Complex64Component, Complex64Component
]
Permitted JSON shape of the fill_value field for complex64.
A two-element JSON array [real, imag] where each component is a
Complex64Component.
__all__
module-attribute
¶
__all__ = [
"COMPLEX64_DATA_TYPE_NAME",
"Complex64Component",
"Complex64DataType",
"Complex64DataTypeName",
"Complex64FillValue",
]
Complex64DataType
dataclass
¶
Bases: ComplexDataType
The complex64 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/complex64.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = COMPLEX64_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.complex128 ¶
Zarr v3 complex128 data type.
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html
COMPLEX128_DATA_TYPE_NAME
module-attribute
¶
COMPLEX128_DATA_TYPE_NAME: Final = 'complex128'
The data_type value for the complex128 type.
Complex128Component
module-attribute
¶
Complex128Component = Float64FillValue
One real or imaginary component of a complex128 fill value.
Same shape as a float64 fill value: a JSON number, a named sentinel,
or a HexFloat64 string.
Complex128DataTypeName
module-attribute
¶
Complex128DataTypeName = Literal['complex128']
Literal type of the data_type field for complex128.
Complex128FillValue
module-attribute
¶
Complex128FillValue = tuple[
Complex128Component, Complex128Component
]
Permitted JSON shape of the fill_value field for complex128.
A two-element JSON array [real, imag] where each component is a
Complex128Component.
__all__
module-attribute
¶
__all__ = [
"COMPLEX128_DATA_TYPE_NAME",
"Complex128Component",
"Complex128DataType",
"Complex128DataTypeName",
"Complex128FillValue",
]
Complex128DataType
dataclass
¶
Bases: ComplexDataType
The complex128 data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/complex128.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = COMPLEX128_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.raw ¶
Zarr v3 r<N> raw-bytes data type (parameterised by bit count).
The data_type value is a string of the form r<N> where N is a
positive multiple of 8 (e.g. r8, r16, r24).
See https://zarr-specs.readthedocs.io/en/latest/v3/data-types/index.html (https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L46-L47; fill value: https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L97-L99)
RAW_BYTES_FAMILY
module-attribute
¶
RAW_BYTES_FAMILY: Final = 'r<N>'
Canonical key for the parameterized raw-bytes data type family.
Spelled as the spec writes the family; the angle brackets keep it unforgeable by a real name.
RAW_BYTES_NAME_PATTERN
module-attribute
¶
The shape of a raw-bytes data type name, not its validity.
ASCII digits only: \d would also match every other Unicode decimal, so
r16 would be read as sixteen bits and a genuine third-party
name spelled that way would be folded into this family.
Matches every r<N> spelling including malformed ones (r0, r12), so
that a misspelled member of this family is recognized as belonging to it
and reported as a misspelling, rather than passing as an unknown
third-party extension. raw_bytes_dtype_name applies the validity rule
on top. Sole owner of this grammar: other modules match through it.
RawBytesDataTypeName
module-attribute
¶
A spec-conformant r<N> raw-bytes name (e.g. "r8", "r16").
"raw bits, variable size given by *, limited to be a multiple of 8": https://github.com/zarr-developers/zarr-specs/blob/fc7dd9c9beb5a50b87f9b08b00bf50fc0048482f/docs/v3/data-types/index.rst#L46-L47
RawBytesFillValue
module-attribute
¶
Permitted JSON shape of the fill_value field for r<N>.
A JSON array of N/8 integers in [0, 255] (one per byte).
__all__
module-attribute
¶
__all__ = [
"RAW_BYTES_FAMILY",
"RAW_BYTES_NAME_PATTERN",
"RawBytesDataType",
"RawBytesDataTypeName",
"RawBytesFillValue",
"raw_bytes_dtype_name",
]
RawBytesDataType
dataclass
¶
Bases: DataTypeEntity
An r<N> raw-bytes data type, coerced from its metadata.
One class for the whole family, because r8 and r4096 differ only
in a number. That is why this is the one entity whose identifier is
not a name any document carries: r<N> is a shape, not a spelling,
and no real name can collide with it.
The spelling is kept rather than the bit count, so a document comes
back out as it went in. r008 is a valid and distinct way of writing
r8, and canonicalizing it away is not this package's call.
Source code in src/zarr_metadata/v3/data_type/raw.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = RAW_BYTES_FAMILY
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Every r<N> spelling, valid or not.
A malformed member of the family is recognized as belonging to it and reported as malformed, rather than passing unjudged as some third party's extension.
Source code in src/zarr_metadata/v3/data_type/raw.py
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/data_type/raw.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
One byte value per byte of the scalar.
A malformed name says nothing about how wide the scalar is, so
there is no length to check against; problems reports the name.
Source code in src/zarr_metadata/v3/data_type/raw.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
N must be a positive multiple of 8.
"raw bits, variable size given by *, limited to be a multiple of 8" -- and zero bits is not a data type.
Source code in src/zarr_metadata/v3/data_type/raw.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/data_type/raw.py
raw_bytes_dtype_name ¶
raw_bytes_dtype_name(value: str) -> RawBytesDataTypeName
Validate value as a r<N> raw-bytes name and brand it.
Raises ValueError if value is not r followed by a positive
multiple of 8.
Source code in src/zarr_metadata/v3/data_type/raw.py
zarr_metadata.v3.data_type.bytes ¶
Zarr bytes data type (variable-length raw bytes, zarr-extensions).
See https://github.com/zarr-developers/zarr-extensions/blob/4da7b37a84f76e660902f6d3de3eaef0e0febae6/data-types/bytes/README.md
BYTES_DATA_TYPE_NAME
module-attribute
¶
BYTES_DATA_TYPE_NAME: Final = 'bytes'
The data_type value for the variable-length bytes type.
Base64Bytes
module-attribute
¶
A standard-alphabet base64-encoded byte sequence.
BytesDataTypeName
module-attribute
¶
BytesDataTypeName = Literal['bytes']
Literal type of the data_type field for bytes.
BytesFillValue
module-attribute
¶
BytesFillValue = tuple[int, ...] | Base64Bytes
Permitted JSON shape of the fill_value field for bytes.
Either a JSON array of integers in [0, 255] (one per byte), or a
Base64Bytes string encoding the byte sequence.
__all__
module-attribute
¶
__all__ = [
"BYTES_DATA_TYPE_NAME",
"Base64Bytes",
"BytesDataType",
"BytesDataTypeName",
"BytesFillValue",
"base64_bytes",
]
BytesDataType
dataclass
¶
Bases: DataTypeEntity
The bytes data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/bytes.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = BYTES_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Base64, or an array of byte values of any length.
Source code in src/zarr_metadata/v3/data_type/bytes.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
base64_bytes ¶
base64_bytes(value: str) -> Base64Bytes
Validate value as a Base64Bytes and brand it.
Raises ValueError if value is not standard-alphabet base64
(length must be a multiple of 4 once padded; only A-Z, a-z,
0-9, +, /, and trailing = padding are permitted).
Source code in src/zarr_metadata/v3/data_type/bytes.py
zarr_metadata.v3.data_type.string ¶
Zarr string data type (variable-length utf-8, zarr-extensions).
See https://github.com/zarr-developers/zarr-extensions/blob/4da7b37a84f76e660902f6d3de3eaef0e0febae6/data-types/string/README.md
STRING_DATA_TYPE_NAME
module-attribute
¶
STRING_DATA_TYPE_NAME: Final = 'string'
The data_type value for the string type.
StringDataTypeName
module-attribute
¶
StringDataTypeName = Literal['string']
Literal type of the data_type field for string.
StringFillValue
module-attribute
¶
StringFillValue = str
Permitted JSON shape of the fill_value field for string: a JSON unicode string.
__all__
module-attribute
¶
StringDataType
dataclass
¶
Bases: DataTypeEntity
The string data type. The name says everything.
Source code in src/zarr_metadata/v3/data_type/string.py
configuration_required
class-attribute
¶
configuration_required: bool = False
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = STRING_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = MappingProxyType({})
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
problems ¶
problems() -> tuple[ValidationProblem, ...]
Every value of this entity the spec disallows.
Locations are relative to the entity's configuration. Default:
an entity whose type admits only valid values has nothing to add.
Source code in src/zarr_metadata/v3/_entity.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> ZarrV3MetadataFieldJSON
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
Source code in src/zarr_metadata/v3/_entity.py
zarr_metadata.v3.data_type.numpy_datetime64 ¶
Zarr numpy.datetime64 data type (zarr-extensions).
See https://github.com/zarr-developers/zarr-extensions/blob/4da7b37a84f76e660902f6d3de3eaef0e0febae6/data-types/numpy.datetime64/README.md
NUMPY_DATETIME64_DATA_TYPE_NAME
module-attribute
¶
NUMPY_DATETIME64_DATA_TYPE_NAME: Final = 'numpy.datetime64'
The name field value of the numpy.datetime64 data type.
NumpyDatetime64DataTypeName
module-attribute
¶
NumpyDatetime64DataTypeName = Literal['numpy.datetime64']
Literal type of the name field of the numpy.datetime64 data type.
NumpyDatetime64FillValue
module-attribute
¶
Permitted JSON shape of the fill_value field for numpy.datetime64.
Either a JSON integer (count of unit * scale_factor since the epoch),
or the string "NaT" (equivalent to the integer -2**63).
NumpyTimeUnit
module-attribute
¶
NumpyTimeUnit = Literal[
"Y",
"M",
"W",
"D",
"h",
"m",
"s",
"ms",
"us",
"μs",
"ns",
"ps",
"fs",
"as",
"generic",
]
Time unit codes used by numpy.datetime64.
__all__
module-attribute
¶
__all__ = [
"NUMPY_DATETIME64_DATA_TYPE_NAME",
"NumpyDatetime64",
"NumpyDatetime64Configuration",
"NumpyDatetime64DataType",
"NumpyDatetime64DataTypeName",
"NumpyDatetime64FillValue",
"NumpyTimeUnit",
]
NumpyDatetime64 ¶
Bases: TypedDict
numpy.datetime64 data type metadata.
Source code in src/zarr_metadata/v3/data_type/numpy_datetime64.py
NumpyDatetime64Configuration ¶
Bases: TypedDict
Configuration for the numpy.datetime64 data type.
Attributes:
-
unit(ReadOnly[NumpyTimeUnit]) –A string encoding a unit of time.
-
scale_factor(ReadOnly[int]) –The multiplier relative to the unit.
Source code in src/zarr_metadata/v3/data_type/numpy_datetime64.py
NumpyDatetime64DataType
dataclass
¶
Bases: NumpyTimeDataType
The numpy.datetime64 data type, coerced from its metadata.
Source code in src/zarr_metadata/v3/data_type/numpy_datetime64.py
configuration_required
class-attribute
¶
configuration_required: bool = True
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = NUMPY_DATETIME64_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = {
"unit": (True, one_of(NUMPY_TIME_UNIT)),
"scale_factor": (True, is_int),
}
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init__ ¶
__init__(
unit: NumpyTimeUnit = "generic",
scale_factor: int = 1,
*,
must_understand: bool = True,
) -> None
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
scale_factor counts units per step, so it is positive.
The upper bound is numpy's: the field is a signed 32-bit integer.
Source code in src/zarr_metadata/v3/data_type/numpy_datetime64.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> NumpyDatetime64
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.
zarr_metadata.v3.data_type.numpy_timedelta64 ¶
Zarr numpy.timedelta64 data type (zarr-extensions).
See https://github.com/zarr-developers/zarr-extensions/blob/4da7b37a84f76e660902f6d3de3eaef0e0febae6/data-types/numpy.timedelta64/README.md
NUMPY_TIMEDELTA64_DATA_TYPE_NAME
module-attribute
¶
NUMPY_TIMEDELTA64_DATA_TYPE_NAME: Final = (
"numpy.timedelta64"
)
The name field value of the numpy.timedelta64 data type.
NUMPY_TIME_MAX_SCALE_FACTOR
module-attribute
¶
NUMPY_TIME_MAX_SCALE_FACTOR: Final = 2 ** 31 - 1
The largest scale_factor numpy stores: the field is a signed int32.
NUMPY_TIME_UNIT
module-attribute
¶
NUMPY_TIME_UNIT: Final = (
"Y",
"M",
"W",
"D",
"h",
"m",
"s",
"ms",
"us",
"μs",
"ns",
"ps",
"fs",
"as",
"generic",
)
Runtime tuple of the permitted numpy.timedelta64/numpy.datetime64 unit strings.
NumpyTimeUnit
module-attribute
¶
NumpyTimeUnit = Literal[
"Y",
"M",
"W",
"D",
"h",
"m",
"s",
"ms",
"us",
"μs",
"ns",
"ps",
"fs",
"as",
"generic",
]
Time unit codes used by numpy.timedelta64.
NumpyTimedelta64DataTypeName
module-attribute
¶
NumpyTimedelta64DataTypeName = Literal['numpy.timedelta64']
Literal type of the name field of the numpy.timedelta64 data type.
NumpyTimedelta64FillValue
module-attribute
¶
Permitted JSON shape of the fill_value field for numpy.timedelta64.
Either a JSON integer (a count of unit * scale_factor), or the string
"NaT" (equivalent to the integer -2**63).
__all__
module-attribute
¶
__all__ = [
"NUMPY_TIMEDELTA64_DATA_TYPE_NAME",
"NUMPY_TIME_MAX_SCALE_FACTOR",
"NUMPY_TIME_UNIT",
"NumpyTimeUnit",
"NumpyTimedelta64",
"NumpyTimedelta64Configuration",
"NumpyTimedelta64DataType",
"NumpyTimedelta64DataTypeName",
"NumpyTimedelta64FillValue",
]
NumpyTimedelta64 ¶
Bases: TypedDict
numpy.timedelta64 data type metadata.
Source code in src/zarr_metadata/v3/data_type/numpy_timedelta64.py
NumpyTimedelta64Configuration ¶
Bases: TypedDict
Configuration for the numpy.timedelta64 data type.
Attributes:
-
unit(ReadOnly[NumpyTimeUnit]) –A string encoding a unit of time.
-
scale_factor(ReadOnly[int]) –The multiplier relative to the unit.
Source code in src/zarr_metadata/v3/data_type/numpy_timedelta64.py
NumpyTimedelta64DataType
dataclass
¶
Bases: NumpyTimeDataType
The numpy.timedelta64 data type, coerced from its metadata.
Source code in src/zarr_metadata/v3/data_type/numpy_timedelta64.py
configuration_required
class-attribute
¶
configuration_required: bool = True
Whether the bare-name spelling says too little for this entity.
The spec permits a bare name "if no configuration metadata is required", so this is true exactly when some member is required.
identifier
class-attribute
¶
identifier: str = NUMPY_TIMEDELTA64_DATA_TYPE_NAME
The name this entity is registered under.
Usually the name the metadata carries. The raw-bytes data types are
the exception: every r<N> spelling is one family, so the family gets
an invented identifier that no real name can collide with.
member_types
class-attribute
¶
member_types: MemberTypes = {
"unit": (True, one_of(NUMPY_TIME_UNIT)),
"scale_factor": (True, is_int),
}
The configuration members, and the type each one takes.
The same keys as the configuration TypedDict, which is the same as the
constructor signature; tests/v3/test_entities.py holds the three
together.
must_understand
class-attribute
instance-attribute
¶
name
property
¶
name: str
The name this entity carries, as a document would write it.
Usually the identifier. They differ for the raw-bytes family,
whose identifier is invented and belongs in no message a reader
sees -- so anything user-facing wants this, and anything looking
something up wants identifier.
required_class_vars
class-attribute
¶
Every class variable a concrete entity of this kind must declare.
twos_complement
class-attribute
¶
twos_complement: bool = False
Whether this type's scalars are two's complement integers.
Asked by cast_value, whose out_of_range: "wrap" is defined only
for such a target. Required rather than defaulted: a data type added
later must decide, because either default would answer for it
silently -- and getting it wrong in one direction accepts a cast the
spec does not define.
__init__ ¶
__init__(
unit: NumpyTimeUnit = "generic",
scale_factor: int = 1,
*,
must_understand: bool = True,
) -> None
__init_subclass__ ¶
Refuse a subclass that forgot to say what it is.
identifier and the per-kind class variables carry no default,
so a subclass omitting one type-checks cleanly and then raises
AttributeError from whichever method is reached first. Saying so
here makes it an import-time error in the extension's own module.
base=True for a class that exists to add a class variable
rather than to be an entity -- CodecEntity, IntegerDataType.
Source code in src/zarr_metadata/v3/_entity.py
accepts
classmethod
¶
Whether name denotes this entity.
Constant for all but the raw-bytes family, where one class covers
every r<N>.
canonical ¶
canonical() -> Self
This entity in the simplest form that means the same thing.
A transformation, asked for by canonicalize_array_metadata_v3
and by nothing else. to_json does not apply it, because writing
a document back is not the same as asking for it to be rewritten:
a reader that reads and writes should not change bytes it was not
asked to change.
Default: entities are already canonical. Override where two
spellings of a member mean the same -- a rectilinear dimension's
run-length encoding, a typesize that noshuffle ignores -- and
where a contained entity has its own canonical form.
Source code in src/zarr_metadata/v3/_entity.py
coerce
classmethod
¶
value as this entity, or the reasons it is not one.
context is the scope this reading is happening in; most entities
have no use for it and ignore it.
Source code in src/zarr_metadata/v3/_entity.py
configuration ¶
This entity's configuration, as the document would write it.
Faithful to every member the entity holds: to_json is
serialization, not canonicalization, so nothing is simplified
here. Override only to render a member that is not already JSON,
such as a contained entity.
Absent optional members are left out, which is what makes the
bare-name spelling reachable. Absence is UNSET, never None:
this package holds None to mean a JSON null the document
actually wrote, and scale_offset is a real case where null
and absent are different documents.
Source code in src/zarr_metadata/v3/_entity.py
fill_value_problems ¶
fill_value_problems(
value: object, loc: Loc = ()
) -> tuple[ValidationProblem, ...]
Why value is not a fill value of this type, if it is not.
Default: nothing. A data type this package does not model accepts whatever its extension says it does, and guessing would reject valid documents.
Source code in src/zarr_metadata/v3/data_type/_families.py
problems ¶
problems() -> tuple[ValidationProblem, ...]
scale_factor counts units per step, so it is positive.
The upper bound is numpy's: the field is a signed 32-bit integer.
Source code in src/zarr_metadata/v3/data_type/numpy_timedelta64.py
storage_class ¶
storage_class() -> StorageClass | None
How one scalar occupies bytes, or None if undetermined.
None only for a composite whose parts are not all in scope: an answer would be a guess, and the rules that ask decline instead.
Source code in src/zarr_metadata/v3/_entity.py
to_json ¶
to_json() -> NumpyTimedelta64
This entity as a document would write it.
Faithful to every member: read a document, write it back, and the
members come out as they went in. Ask canonical first if you
want the simplest equivalent spelling.
What is not preserved is the envelope's spelling, because the
entity does not model it: a bare name, {"name": x}, and
{"name": x, "configuration": {}} all mean the same and all read
to the same entity, so all three write back as the bare name.
must_understand is omitted when true, which is its default; an
explicit false is kept, because that one says something.
Subclasses narrow the return type to their own object TypedDict, which is the JSON form this dataclass models.