Skip to content

Commit a3b797d

Browse files
committed
docs, tests
1 parent 73ea1d2 commit a3b797d

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

src/zarr/_info.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,37 @@
22
import textwrap
33
from typing import Literal
44

5-
# Group
6-
# Name : /
7-
# Type : zarr.hierarchy.Group
8-
# Read-only : False
9-
# Store type : zarr.storage.MemoryStore
10-
# No. members : 0
11-
# No. arrays : 0
12-
# No. groups : 0
13-
145

156
@dataclasses.dataclass(kw_only=True)
167
class GroupInfo:
8+
"""
9+
Information about a group.
10+
11+
Parameters
12+
----------
13+
name : str
14+
The path of the group within the Store
15+
type : "Group"
16+
zarr_format : {2, 3}
17+
The zarr format of the Group.
18+
read_only : bool
19+
Whether the Group's access mode is read only.
20+
store_type : str
21+
The name of the Store class containing this group.
22+
count_members : int, optional
23+
The number of child members below this group. This
24+
will be set when the Group has consolidated metadata
25+
or when using :class:`Group.info_complete`.
26+
count_arrays : int, optional
27+
The number of child arrays below this group. This
28+
will be set when the Group has consolidated metadata
29+
or when using :class:`Group.info_complete`.
30+
count_groups : int, optional
31+
The number of child groups below this group. This
32+
will be set when the Group has consolidated metadata
33+
or when using :class:`Group.info_complete`.
34+
"""
35+
1736
name: str
1837
type: Literal["Group"] = "Group"
1938
zarr_format: Literal[2, 3]

tests/v3/test_info.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from zarr._info import ArrayInfo, GroupInfo
5+
from zarr._info import ArrayInfo, GroupInfo, human_readable_size
66
from zarr.core.common import ZarrFormat
77

88
ZARR_FORMATS = [2, 3]
@@ -111,3 +111,19 @@ def test_array_info_complete(
111111
No. bytes stored : {count_bytes_stored_formatted}
112112
Storage ratio : {storage_ratio_formatted}
113113
Chunks Initialized : 5""")
114+
115+
116+
@pytest.mark.parametrize(
117+
("size", "expected"),
118+
[
119+
(1, "1"),
120+
(2**10, "1.0K"),
121+
(2**20, "1.0M"),
122+
(2**30, "1.0G"),
123+
(2**40, "1.0T"),
124+
(2**50, "1.0P"),
125+
],
126+
)
127+
def test_human_readable_size(size: int, expected: str) -> None:
128+
result = human_readable_size(size)
129+
assert result == expected

0 commit comments

Comments
 (0)