Skip to content

Commit b90d8f3

Browse files
committed
merged
2 parents 717f0c7 + 01346dd commit b90d8f3

File tree

1 file changed

+9
-7
lines changed
  • src/zarr/core/metadata

1 file changed

+9
-7
lines changed

src/zarr/core/metadata/v3.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from zarr.registry import get_codec_class
3232
from zarr.strings import STRING_DTYPE
3333

34+
DEFAULT_DTYPE = "float64"
35+
3436

3537
def parse_zarr_format(data: object) -> Literal[3]:
3638
if data == 3:
@@ -184,14 +186,14 @@ def __init__(
184186
chunk_grid_parsed = ChunkGrid.from_dict(chunk_grid)
185187
chunk_key_encoding_parsed = ChunkKeyEncoding.from_dict(chunk_key_encoding)
186188
dimension_names_parsed = parse_dimension_names(dimension_names)
187-
fill_value_parsed = parse_fill_value(fill_value, dtype=data_type_parsed.to_numpy_dtype())
189+
fill_value_parsed = parse_fill_value(fill_value, dtype=data_type_parsed.to_numpy())
188190
attributes_parsed = parse_attributes(attributes)
189191
codecs_parsed_partial = parse_codecs(codecs)
190192
storage_transformers_parsed = parse_storage_transformers(storage_transformers)
191193

192194
array_spec = ArraySpec(
193195
shape=shape_parsed,
194-
dtype=data_type_parsed.to_numpy_dtype(),
196+
dtype=data_type_parsed.to_numpy(),
195197
fill_value=fill_value_parsed,
196198
order="C", # TODO: order is not needed here.
197199
prototype=default_buffer_prototype(), # TODO: prototype is not needed here.
@@ -225,13 +227,13 @@ def _validate_metadata(self) -> None:
225227
raise ValueError("`fill_value` is required.")
226228
for codec in self.codecs:
227229
codec.validate(
228-
shape=self.shape, dtype=self.data_type.to_numpy_dtype(), chunk_grid=self.chunk_grid
230+
shape=self.shape, dtype=self.data_type.to_numpy(), chunk_grid=self.chunk_grid
229231
)
230232

231233
@property
232234
def dtype(self) -> np.dtype[Any]:
233235
"""Interpret Zarr dtype as NumPy dtype"""
234-
return self.data_type.to_numpy_dtype()
236+
return self.data_type.to_numpy()
235237

236238
@property
237239
def ndim(self) -> int:
@@ -494,14 +496,14 @@ def to_numpy_shortname(self) -> str:
494496
}
495497
return data_type_to_numpy[self]
496498

497-
def to_numpy_dtype(self) -> np.dtype[Any]:
499+
def to_numpy(self) -> np.dtype[Any]:
498500
if self == DataType.string:
499501
return STRING_DTYPE
500502
else:
501503
return np.dtype(self.to_numpy_shortname())
502504

503505
@classmethod
504-
def from_numpy_dtype(cls, dtype: np.dtype[Any]) -> DataType:
506+
def from_numpy(cls, dtype: np.dtype[Any]) -> DataType:
505507
if np.issubdtype(np.str_, dtype):
506508
return DataType.string
507509
dtype_to_data_type = {
@@ -540,7 +542,7 @@ def parse(cls, dtype: None | DataType | Any) -> DataType:
540542
raise ValueError(f"Invalid V3 data_type: {dtype}") from e
541543
# check that this is a valid v3 data_type
542544
try:
543-
data_type = DataType.from_numpy_dtype(dtype)
545+
data_type = DataType.from_numpy(dtype)
544546
except KeyError as e:
545547
raise ValueError(f"Invalid V3 data_type: {dtype}") from e
546548
return data_type

0 commit comments

Comments
 (0)