Skip to content

Commit 23bfef5

Browse files
committed
docstrings
1 parent 7a718d5 commit 23bfef5

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/zarr/core/group.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,15 +3096,22 @@ def _parse_hierarchy_dict(
30963096
data: Mapping[str, GroupMetadata | ArrayV2Metadata | ArrayV3Metadata],
30973097
) -> dict[str, GroupMetadata | ArrayV2Metadata | ArrayV3Metadata]:
30983098
"""
3099+
Take an input Mapping of str: node pairs, and parse it into
3100+
a dict of str: node pairs that models valid, complete Zarr hierarchy.
3101+
30993102
If the input represents a complete Zarr hierarchy, i.e. one with no implicit groups,
3100-
then return an identical copy of that dict. Otherwise, return a version of the input dict
3101-
with groups added where they are needed to make the hierarchy explicit.
3103+
then return a dict with the exact same data as the input.
3104+
3105+
Otherwise, return a dict derived from the input with groups as needed to make
3106+
the hierarchy complete.
31023107
3103-
For example, an input of {'a/b/c': ArrayMetadata} will result in a return value of
3104-
{'a': GroupMetadata, 'a/b': GroupMetadata, 'a/b/c': ArrayMetadata}.
3108+
For example, an input of {'a/b/c': ArrayMetadata} is incomplete, because it references two
3109+
groups ('a' and 'a/b') but these keys are not present in the input. Applying this function
3110+
to that input will result in a return value of
3111+
{'a': GroupMetadata, 'a/b': GroupMetadata, 'a/b/c': ArrayMetadata}, i.e. the implied groups
3112+
were added.
31053113
3106-
The input is also checked for the following conditions, and an error is raised if any
3107-
of them are violated:
3114+
The input is also checked for the following conditions; an error is raised if any are violated:
31083115
31093116
- No arrays can contain group or arrays (i.e., all arrays must be leaf nodes).
31103117
- All arrays and groups must have the same ``zarr_format`` value.
@@ -3179,18 +3186,21 @@ def _normalize_paths(paths: Iterable[str]) -> tuple[str, ...]:
31793186
def _normalize_path_keys(data: Mapping[str, T]) -> dict[str, T]:
31803187
"""
31813188
Normalize the keys of the input dict according to the normalization scheme used for zarr node
3182-
paths. If any two keys in the input normalize to the value, raise a ValueError. Return the
3183-
values of data with the normalized keys.
3189+
paths. If any two keys in the input normalize to the same value, raise a ValueError.
3190+
Returns a dict where the keys are the elements of the input and the values are the
3191+
normalized form of each key.
31843192
"""
31853193
parsed_keys = _normalize_paths(data.keys())
3186-
return dict(zip(parsed_keys, data.values(), strict=False))
3194+
return dict(zip(parsed_keys, data.values(), strict=True))
31873195

31883196

31893197
async def _getitem_semaphore(
31903198
node: AsyncGroup, key: str, semaphore: asyncio.Semaphore | None
31913199
) -> AsyncArray[ArrayV3Metadata] | AsyncArray[ArrayV2Metadata] | AsyncGroup:
31923200
"""
3193-
Combine node.getitem with an optional semaphore. If the semaphore parameter is an
3201+
Wrap Group.getitem with an optional semaphore.
3202+
3203+
If the semaphore parameter is an
31943204
asyncio.Semaphore instance, then the getitem operation is performed inside an async context
31953205
manager provided by that semaphore. If the semaphore parameter is None, then getitem is invoked
31963206
without a context manager.

0 commit comments

Comments
 (0)