Skip to content

Commit 035f53a

Browse files
committed
fixup
1 parent cdb1672 commit 035f53a

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

src/zarr/core/_info.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import dataclasses
22
import textwrap
3-
from typing import Literal
3+
from typing import Any, Literal
4+
5+
import numcodecs.abc
6+
import numpy as np
7+
8+
from zarr.abc.codec import Codec
9+
from zarr.core.metadata.v3 import DataType
410

511

612
@dataclasses.dataclass(kw_only=True)
@@ -92,15 +98,15 @@ class ArrayInfo:
9298

9399
_type: Literal["Array"] = "Array"
94100
_zarr_format: Literal[2, 3]
95-
_data_type: str
101+
_data_type: np.dtype[Any] | DataType
96102
_shape: tuple[int, ...]
97103
_chunk_shape: tuple[int, ...] | None = None
98104
_order: Literal["C", "F"]
99105
_read_only: bool
100106
_store_type: str
101-
_compressor: str | None = None
102-
_filters: list[str] | None = None
103-
_codecs: str | None = None
107+
_compressor: numcodecs.abc.Codec | None = None
108+
_filters: tuple[numcodecs.abc.Codec, ...] | None = None
109+
_codecs: tuple[Codec, ...] | None = None
104110
_count_bytes: int | None = None
105111
_count_bytes_stored: int | None = None
106112
_count_chunks_initialized: int | None = None

src/zarr/core/array.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,18 +1365,18 @@ def _info(self, extra: dict[str, int] | None = None) -> Any:
13651365
if self.metadata.zarr_format == 2:
13661366
assert isinstance(self.metadata, ArrayV2Metadata)
13671367
if self.metadata.compressor is not None:
1368-
kwargs["compressor"] = str(self.metadata.compressor)
1368+
kwargs["_compressor"] = self.metadata.compressor
13691369
if self.metadata.filters is not None:
1370-
kwargs["filters"] = str(self.metadata.filters)
1371-
kwargs["data_type"] = str(self.metadata.dtype)
1372-
kwargs["chunk_shape"] = self.metadata.chunks
1370+
kwargs["_filters"] = self.metadata.filters
1371+
kwargs["_data_type"] = self.metadata.dtype
1372+
kwargs["_chunk_shape"] = self.metadata.chunks
13731373
else:
1374-
kwargs["codecs"] = str(self.metadata.codecs)
1375-
kwargs["data_type"] = str(self.metadata.data_type)
1374+
kwargs["_codecs"] = self.metadata.codecs
1375+
kwargs["_data_type"] = self.metadata.data_type
13761376
# just regular?
13771377
chunk_grid = self.metadata.chunk_grid
13781378
if isinstance(chunk_grid, RegularChunkGrid):
1379-
kwargs["chunk_shape"] = chunk_grid.chunk_shape
1379+
kwargs["_chunk_shape"] = chunk_grid.chunk_shape
13801380
else:
13811381
raise NotImplementedError(
13821382
"'info' is not yet implemented for chunk grids of type {type(self.metadata.chunk_grid)}"

tests/test_array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from zarr.core.common import JSON, MemoryOrder, ZarrFormat
1818
from zarr.core.group import AsyncGroup
1919
from zarr.core.indexing import ceildiv
20+
from zarr.core.metadata.v3 import DataType
2021
from zarr.core.sync import sync
2122
from zarr.errors import ContainsArrayError, ContainsGroupError
2223
from zarr.storage import LocalStore, MemoryStore
@@ -425,7 +426,7 @@ def test_info_v2(self) -> None:
425426
result = arr.info
426427
expected = ArrayInfo(
427428
_zarr_format=2,
428-
_data_type="float64",
429+
_data_type=np.dtype("float64"),
429430
_shape=(4, 4),
430431
_chunk_shape=(2, 2),
431432
_order="C",
@@ -440,13 +441,13 @@ def test_info_v3(self) -> None:
440441
result = arr.info
441442
expected = ArrayInfo(
442443
_zarr_format=3,
443-
_data_type="DataType.float64",
444+
_data_type=DataType.parse("float64"),
444445
_shape=(4, 4),
445446
_chunk_shape=(2, 2),
446447
_order="C",
447448
_read_only=False,
448449
_store_type="MemoryStore",
449-
_codecs="[BytesCodec(endian=<Endian.little: 'little'>)]",
450+
_codecs=(BytesCodec(),),
450451
_count_bytes=128,
451452
)
452453
assert result == expected

tests/test_group.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,22 +1356,22 @@ def test_info(self):
13561356

13571357
result = A.info
13581358
expected = GroupInfo(
1359-
name="A",
1360-
read_only=False,
1361-
store_type="MemoryStore",
1362-
zarr_format=3,
1359+
_name="A",
1360+
_read_only=False,
1361+
_store_type="MemoryStore",
1362+
_zarr_format=3,
13631363
)
13641364
assert result == expected
13651365

13661366
result = A.info_complete()
13671367
expected = GroupInfo(
1368-
name="A",
1369-
read_only=False,
1370-
store_type="MemoryStore",
1371-
zarr_format=3,
1372-
count_members=3,
1373-
count_arrays=2,
1374-
count_groups=1,
1368+
_name="A",
1369+
_read_only=False,
1370+
_store_type="MemoryStore",
1371+
_zarr_format=3,
1372+
_count_members=3,
1373+
_count_arrays=2,
1374+
_count_groups=1,
13751375
)
13761376
assert result == expected
13771377

0 commit comments

Comments
 (0)