3030from zarr .core .metadata .common import ArrayMetadata , parse_attributes
3131from zarr .registry import get_codec_class
3232
33+ DEFAULT_DTYPE = "float64"
34+
3335
3436def parse_zarr_format (data : object ) -> Literal [3 ]:
3537 if data == 3 :
@@ -183,14 +185,14 @@ def __init__(
183185 chunk_grid_parsed = ChunkGrid .from_dict (chunk_grid )
184186 chunk_key_encoding_parsed = ChunkKeyEncoding .from_dict (chunk_key_encoding )
185187 dimension_names_parsed = parse_dimension_names (dimension_names )
186- fill_value_parsed = parse_fill_value (fill_value , dtype = data_type_parsed .to_numpy_dtype ())
188+ fill_value_parsed = parse_fill_value (fill_value , dtype = data_type_parsed .to_numpy ())
187189 attributes_parsed = parse_attributes (attributes )
188190 codecs_parsed_partial = parse_codecs (codecs )
189191 storage_transformers_parsed = parse_storage_transformers (storage_transformers )
190192
191193 array_spec = ArraySpec (
192194 shape = shape_parsed ,
193- dtype = data_type_parsed .to_numpy_dtype (),
195+ dtype = data_type_parsed .to_numpy (),
194196 fill_value = fill_value_parsed ,
195197 order = "C" , # TODO: order is not needed here.
196198 prototype = default_buffer_prototype (), # TODO: prototype is not needed here.
@@ -224,13 +226,13 @@ def _validate_metadata(self) -> None:
224226 raise ValueError ("`fill_value` is required." )
225227 for codec in self .codecs :
226228 codec .validate (
227- shape = self .shape , dtype = self .data_type .to_numpy_dtype (), chunk_grid = self .chunk_grid
229+ shape = self .shape , dtype = self .data_type .to_numpy (), chunk_grid = self .chunk_grid
228230 )
229231
230232 @property
231233 def dtype (self ) -> np .dtype [Any ]:
232234 """Interpret Zarr dtype as NumPy dtype"""
233- return self .data_type .to_numpy_dtype ()
235+ return self .data_type .to_numpy ()
234236
235237 @property
236238 def ndim (self ) -> int :
@@ -492,11 +494,11 @@ def to_numpy_shortname(self) -> str:
492494 }
493495 return data_type_to_numpy [self ]
494496
495- def to_numpy_dtype (self ) -> np .dtype [Any ]:
497+ def to_numpy (self ) -> np .dtype [Any ]:
496498 return np .dtype (self .to_numpy_shortname ())
497499
498500 @classmethod
499- def from_numpy_dtype (cls , dtype : np .dtype [Any ]) -> DataType :
501+ def from_numpy (cls , dtype : np .dtype [Any ]) -> DataType :
500502 dtype_to_data_type = {
501503 "|b1" : "bool" ,
502504 "bool" : "bool" ,
@@ -520,7 +522,7 @@ def from_numpy_dtype(cls, dtype: np.dtype[Any]) -> DataType:
520522 def parse (cls , dtype : None | DataType | Any ) -> DataType :
521523 if dtype is None :
522524 # the default dtype
523- return DataType . float64
525+ return DataType [ DEFAULT_DTYPE ]
524526 if isinstance (dtype , DataType ):
525527 return dtype
526528 else :
@@ -530,7 +532,7 @@ def parse(cls, dtype: None | DataType | Any) -> DataType:
530532 raise ValueError (f"Invalid V3 data_type: { dtype } " ) from e
531533 # check that this is a valid v3 data_type
532534 try :
533- data_type = DataType .from_numpy_dtype (dtype )
535+ data_type = DataType .from_numpy (dtype )
534536 except KeyError as e :
535537 raise ValueError (f"Invalid V3 data_type: { dtype } " ) from e
536538 return data_type
0 commit comments