|
6 | 6 | import logging |
7 | 7 | from collections import defaultdict |
8 | 8 | from dataclasses import asdict, dataclass, field, fields, replace |
9 | | -from enum import Enum |
10 | 9 | from typing import TYPE_CHECKING, Literal, TypeVar, assert_never, cast, overload |
11 | 10 |
|
12 | | -import numcodecs.abc |
13 | 11 | import numpy as np |
14 | 12 | import numpy.typing as npt |
15 | 13 | from typing_extensions import deprecated |
@@ -99,36 +97,6 @@ def _parse_async_node( |
99 | 97 | raise TypeError(f"Unknown node type, got {type(node)}") |
100 | 98 |
|
101 | 99 |
|
102 | | -def _json_convert(o: object) -> Any: |
103 | | - if isinstance(o, np.dtype): |
104 | | - return str(o) |
105 | | - if np.isscalar(o): |
106 | | - out: Any |
107 | | - if hasattr(o, "dtype") and o.dtype.kind == "M" and hasattr(o, "view"): |
108 | | - # https://github.com/zarr-developers/zarr-python/issues/2119 |
109 | | - # `.item()` on a datetime type might or might not return an |
110 | | - # integer, depending on the value. |
111 | | - # Explicitly cast to an int first, and then grab .item() |
112 | | - out = o.view("i8").item() |
113 | | - else: |
114 | | - # convert numpy scalar to python type, and pass |
115 | | - # python types through |
116 | | - out = getattr(o, "item", lambda: o)() |
117 | | - if isinstance(out, complex): |
118 | | - # python complex types are not JSON serializable, so we use the |
119 | | - # serialization defined in the zarr v3 spec |
120 | | - return [out.real, out.imag] |
121 | | - return out |
122 | | - if isinstance(o, Enum): |
123 | | - return o.name |
124 | | - # this serializes numcodecs compressors |
125 | | - # todo: implement to_dict for codecs |
126 | | - elif isinstance(o, numcodecs.abc.Codec): |
127 | | - config: dict[str, Any] = o.get_config() |
128 | | - return config |
129 | | - raise TypeError |
130 | | - |
131 | | - |
132 | 100 | @dataclass(frozen=True) |
133 | 101 | class ConsolidatedMetadata: |
134 | 102 | """ |
|
0 commit comments