2929@dataclass (frozen = True , kw_only = True )
3030class ArrayV2Metadata (ArrayMetadata ):
3131 shape : ChunkCoords
32- chunk_grid : RegularChunkGrid
33- data_type : np .dtype [Any ]
32+ chunks : RegularChunkGrid
33+ dtype : np .dtype [Any ]
3434 fill_value : None | int | float = 0
3535 order : Literal ["C" , "F" ] = "C"
3636 filters : tuple [numcodecs .abc .Codec , ...] | None = None
@@ -56,18 +56,18 @@ def __init__(
5656 Metadata for a Zarr version 2 array.
5757 """
5858 shape_parsed = parse_shapelike (shape )
59- data_type_parsed = parse_dtype (dtype )
59+ dtype_parsed = parse_dtype (dtype )
6060 chunks_parsed = parse_shapelike (chunks )
6161 compressor_parsed = parse_compressor (compressor )
6262 order_parsed = parse_indexing_order (order )
6363 dimension_separator_parsed = parse_separator (dimension_separator )
6464 filters_parsed = parse_filters (filters )
65- fill_value_parsed = parse_fill_value (fill_value , dtype = data_type_parsed )
65+ fill_value_parsed = parse_fill_value (fill_value , dtype = dtype_parsed )
6666 attributes_parsed = parse_attributes (attributes )
6767
6868 object .__setattr__ (self , "shape" , shape_parsed )
69- object .__setattr__ (self , "data_type " , data_type_parsed )
70- object .__setattr__ (self , "chunk_grid " , RegularChunkGrid (chunk_shape = chunks_parsed ))
69+ object .__setattr__ (self , "dtype " , dtype_parsed )
70+ object .__setattr__ (self , "chunks " , RegularChunkGrid (chunk_shape = chunks_parsed ))
7171 object .__setattr__ (self , "compressor" , compressor_parsed )
7272 object .__setattr__ (self , "order" , order_parsed )
7373 object .__setattr__ (self , "dimension_separator" , dimension_separator_parsed )
@@ -83,12 +83,12 @@ def ndim(self) -> int:
8383 return len (self .shape )
8484
8585 @property
86- def dtype (self ) -> np .dtype [Any ]:
87- return self .data_type
86+ def data_type (self ) -> np .dtype [Any ]:
87+ return self .dtype
8888
8989 @property
90- def chunks (self ) -> ChunkCoords :
91- return self .chunk_grid . chunk_shape
90+ def chunk_grid (self ) -> RegularChunkGrid :
91+ return self .chunks
9292
9393 def to_buffer_dict (self , prototype : BufferPrototype ) -> dict [str , Buffer ]:
9494 def _json_convert (
@@ -145,18 +145,18 @@ def from_dict(cls, data: dict[str, Any]) -> ArrayV2Metadata:
145145 def to_dict (self ) -> dict [str , JSON ]:
146146 zarray_dict = super ().to_dict ()
147147 _ = zarray_dict .pop ("chunk_grid" )
148- zarray_dict ["chunks" ] = self .chunk_grid .chunk_shape
148+ zarray_dict ["chunks" ] = self .chunks .chunk_shape
149149
150- _ = zarray_dict .pop ("data_type " )
151- zarray_dict ["dtype" ] = self .data_type .str
150+ _ = zarray_dict .pop ("dtype " )
151+ zarray_dict ["dtype" ] = self .dtype .str
152152
153153 return zarray_dict
154154
155155 def get_chunk_spec (
156156 self , _chunk_coords : ChunkCoords , order : Literal ["C" , "F" ], prototype : BufferPrototype
157157 ) -> ArraySpec :
158158 return ArraySpec (
159- shape = self .chunk_grid .chunk_shape ,
159+ shape = self .chunks .chunk_shape ,
160160 dtype = self .dtype ,
161161 fill_value = self .fill_value ,
162162 order = order ,
@@ -220,7 +220,7 @@ def parse_compressor(data: object) -> numcodecs.abc.Codec | None:
220220
221221
222222def parse_metadata (data : ArrayV2Metadata ) -> ArrayV2Metadata :
223- if (l_chunks := len (data .chunks )) != (l_shape := len (data .shape )):
223+ if (l_chunks := len (data .chunk_grid . chunk_shape )) != (l_shape := len (data .shape )):
224224 msg = (
225225 f"The `shape` and `chunks` attributes must have the same length. "
226226 f"`chunks` has length { l_chunks } , but `shape` has length { l_shape } ."
0 commit comments