-
-
Notifications
You must be signed in to change notification settings - Fork 402
Expand file tree
/
Copy path__init__.py
More file actions
44 lines (38 loc) · 1.16 KB
/
__init__.py
File metadata and controls
44 lines (38 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
import numpy as np
from zarr.codecs.blosc import BloscCname, BloscCodec, BloscShuffle
from zarr.codecs.bytes import BytesCodec, Endian
from zarr.codecs.crc32c_ import Crc32cCodec
from zarr.codecs.gzip import GzipCodec
from zarr.codecs.sharding import ShardingCodec, ShardingCodecIndexLocation
from zarr.codecs.transpose import TransposeCodec
from zarr.codecs.vlen_utf8 import VLenBytesCodec, VLenUTF8Codec
from zarr.codecs.zstd import ZstdCodec
from zarr.core.metadata.v3 import DataType
__all__ = [
"BloscCname",
"BloscCodec",
"BloscShuffle",
"BytesCodec",
"Crc32cCodec",
"Endian",
"GzipCodec",
"ShardingCodec",
"ShardingCodecIndexLocation",
"TransposeCodec",
"VLenBytesCodec",
"VLenUTF8Codec",
"ZstdCodec",
]
def _get_default_array_bytes_codec(
np_dtype: np.dtype[Any],
) -> BytesCodec | VLenUTF8Codec | VLenBytesCodec:
dtype = DataType.from_numpy(np_dtype)
if dtype == DataType.string:
return VLenUTF8Codec()
elif dtype == DataType.bytes:
return VLenBytesCodec()
else:
return BytesCodec()