Skip to content

Commit 77264e4

Browse files
committed
docstring examples
1 parent 35afe7f commit 77264e4

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/zarr/core/group.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,17 +2942,15 @@ async def create_hierarchy(
29422942
29432943
Examples
29442944
--------
2945-
from zarr.api.asynchronous import create_hierarchy
2946-
from zarr.storage import MemoryStore
2947-
from zarr.core.group import GroupMetadata
2948-
import asyncio
2949-
store = MemoryStore()
2950-
nodes = {'a': GroupMetadata(attributes={'name': 'leaf'})}
2951-
2952-
async def run():
2953-
print(dict([x async for x in create_hierarchy(store=store, nodes=nodes)]))
2954-
2955-
asyncio.run(run())
2945+
>>> from zarr.api.asynchronous import create_hierarchy
2946+
>>> from zarr.storage import MemoryStore
2947+
>>> from zarr.core.group import GroupMetadata
2948+
>>> import asyncio
2949+
>>> store = MemoryStore()
2950+
>>> nodes = {'a': GroupMetadata(attributes={'name': 'leaf'})}
2951+
>>> async def run():
2952+
... print(dict([x async for x in create_hierarchy(store=store, nodes=nodes)]))
2953+
>>> asyncio.run(run())
29562954
# {'a': <AsyncGroup memory://140345143770112/a>, '': <AsyncGroup memory://140345143770112>}
29572955
"""
29582956
# normalize the keys to be valid paths

src/zarr/core/sync_group.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ def create_hierarchy(
9494
9595
Examples
9696
--------
97-
from zarr import create_hierarchy
98-
from zarr.storage import MemoryStore
99-
from zarr.core.group import GroupMetadata
100-
101-
store = MemoryStore()
102-
nodes = {'a': GroupMetadata(attributes={'name': 'leaf'})}
103-
nodes_created = dict(create_hierarchy(store=store, nodes=nodes))
104-
print(nodes)
97+
>>> from zarr import create_hierarchy
98+
>>> from zarr.storage import MemoryStore
99+
>>> from zarr.core.group import GroupMetadata
100+
101+
>>> store = MemoryStore()
102+
>>> nodes = {'a': GroupMetadata(attributes={'name': 'leaf'})}
103+
>>> nodes_created = dict(create_hierarchy(store=store, nodes=nodes))
104+
>>> print(nodes)
105105
# {'a': GroupMetadata(attributes={'name': 'leaf'}, zarr_format=3, consolidated_metadata=None, node_type='group')}
106106
"""
107107
coro = create_hierarchy_async(store=store, nodes=nodes, overwrite=overwrite)

0 commit comments

Comments
 (0)