Skip to content

Update dtype usage in zarr/meta.py #700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from zarr.errors import MetadataError
from zarr.util import json_dumps, json_loads

from typing import Union, Any, List, Mapping as MappingType
from typing import cast, Union, Any, List, Mapping as MappingType

ZARR_FORMAT = 2

Expand Down Expand Up @@ -75,7 +75,7 @@ def encode_array_metadata(meta: MappingType[str, Any]) -> bytes:
return json_dumps(meta)


def encode_dtype(d: np.dtype) -> str:
def encode_dtype(d: np.dtype):
if d.fields is None:
return d.str
else:
Expand Down Expand Up @@ -180,8 +180,9 @@ def encode_fill_value(v: Any, dtype: np.dtype) -> Any:
elif dtype.kind == 'b':
return bool(v)
elif dtype.kind in 'c':
v = (encode_fill_value(v.real, dtype.type().real.dtype),
encode_fill_value(v.imag, dtype.type().imag.dtype))
c = cast(np.complex128, np.dtype(complex).type())
v = (encode_fill_value(v.real, c.real.dtype),
encode_fill_value(v.imag, c.imag.dtype))
return v
elif dtype.kind in 'SV':
v = str(base64.standard_b64encode(v), 'ascii')
Expand Down