v3
NodeSpec #
Bases: StrictBase
The base class for V3 ArraySpec and GroupSpec.
Attributes:
Name | Type | Description |
---|---|---|
zarr_format |
Literal[3]
|
The Zarr version represented by this node. Must be 3. |
ArraySpec #
Bases: NodeSpec
, Generic[TAttr]
A model of a Zarr Version 3 Array.
Attributes:
Name | Type | Description |
---|---|---|
node_type |
Literal['array']
|
The node type. Must be the string 'array'. |
attributes |
TAttr
|
User-defined metadata associated with this array. |
shape |
Sequence[int]
|
The shape of this array. |
data_type |
str
|
The data type of this array. |
chunk_grid |
NamedConfig
|
A |
chunk_key_encoding |
NamedConfig
|
A |
fill_value |
FillValue
|
The fill value for this array. |
codecs |
Sequence[NamedConfig]
|
The sequence of codices for this array. |
storage_transformers |
Optional[Sequence[NamedConfig]]
|
An optional sequence of |
dimension_names |
Optional[Sequence[str]]
|
An optional sequence of strings that gives names to each axis of the array. |
from_array
classmethod
#
Create an ArraySpec from a numpy array-like object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array |
object that conforms to the numpy array API.
|
The shape and dtype of this object will be used to construct an ArraySpec.
If the |
required |
**kwargs |
keyword arguments to the ArraySpec class constructor.
|
|
{}
|
Returns:
Type | Description |
---|---|
An instance of ArraySpec with properties derived from the provided array.
|
|
Source code in src/pydantic_zarr/v3.py
from_zarr
classmethod
#
Create an ArraySpec from a zarr array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
zarray |
zarr array
|
|
required |
Returns:
Type | Description |
---|---|
An instance of ArraySpec with properties derived from the provided zarr
|
|
array.
|
|
Source code in src/pydantic_zarr/v3.py
to_zarr #
Serialize an ArraySpec to a zarr array at a specific path in a zarr store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
store |
instance of zarr.BaseStore
|
The storage backend that will manifest the array. |
required |
path |
str
|
The location of the array inside the store. |
required |
overwrite |
bool
|
Whether to overwrite an existing array or group at the path. If overwrite is False and an array or group already exists at the path, an exception will be raised. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
A zarr array that is structurally identical to the ArraySpec.
|
|
This operation will create metadata documents in the store.
|
|
Source code in src/pydantic_zarr/v3.py
GroupSpec #
Bases: NodeSpec
, Generic[TAttr, TItem]
A model of a Zarr Version 3 Group.
Attributes:
Name | Type | Description |
---|---|---|
node_type |
Literal['group']
|
The type of this node. Must be the string "group". |
attributes |
TAttr
|
The user-defined attributes of this group. |
members |
dict[str, TItem]
|
The members of this group. |
from_zarr
classmethod
#
Create a GroupSpec from a zarr group. Subgroups and arrays contained in the zarr group will be converted to instances of GroupSpec and ArraySpec, respectively, and these spec instances will be stored in the .members attribute of the parent GroupSpec. This occurs recursively, so the entire zarr hierarchy below a given group can be represented as a GroupSpec.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
zarr group
|
|
required |
Returns:
Type | Description |
---|---|
An instance of GroupSpec that represents the structure of the zarr hierarchy.
|
|
Source code in src/pydantic_zarr/v3.py
to_zarr #
Serialize a GroupSpec to a zarr group at a specific path in a zarr store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
store |
instance of zarr.BaseStore
|
The storage backend that will manifest the group and its contents. |
required |
path |
str
|
The location of the group inside the store. |
required |
overwrite |
bool
|
Whether to overwrite an existing array or group at the path. If overwrite is False and an array or group already exists at the path, an exception will be raised. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
A zarr group that is structurally identical to the GroupSpec.
|
|
This operation will create metadata documents in the store.
|
|
Source code in src/pydantic_zarr/v3.py
from_zarr #
Recursively parse a Zarr group or Zarr array into an ArraySpec or GroupSpec.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element |
a zarr Array or zarr Group
|
|
required |
Returns:
Type | Description |
---|---|
An instance of GroupSpec or ArraySpec that represents the
|
|
structure of the zarr group or array.
|
|
Source code in src/pydantic_zarr/v3.py
to_zarr #
Serialize a GroupSpec or ArraySpec to a zarr group or array at a specific path in a zarr store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spec |
GroupSpec or ArraySpec
|
The GroupSpec or ArraySpec that will be serialized to storage. |
required |
store |
instance of zarr.BaseStore
|
The storage backend that will manifest the group or array. |
required |
path |
str
|
The location of the group or array inside the store. |
required |
overwrite |
bool
|
Whether to overwrite an existing array or group at the path. If overwrite is False and an array or group already exists at the path, an exception will be raised. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
A zarr Group or Array that is structurally equivalent to the spec object.
|
|
This operation will create metadata documents in the store.
|
|