Skip to content

Commit 9243fc7

Browse files
committed
more async docs
1 parent de9c8aa commit 9243fc7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

docs/user-guide/async.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@ The usage of the async API mirrors the synchronous API.
88

99
.. ipython:: python
1010
11+
import asyncio
12+
import numpy as np
1113
import zarr.api.asynchronous as async_zarr
1214
13-
z = await async_zarr.open(mode='w', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4')
15+
# create a new group using the asynchronous API
16+
root = await async_zarr.group(attributes={'foo': 'bar'})
17+
root
18+
# create an array using the AsyncGroup
19+
z = await root.create_array(name='foo', shape=(100, ), chunks=(5, ), dtype='i4')
1420
z
15-
16-
await z.setitem((0, 0), 42)
17-
18-
await z.getitem((slice(0, 4), slice(0, 1)))
21+
# set and get items
22+
await z.setitem((slice(None), ), np.arange(0, 100, dtype=z.dtype))
23+
# set a single item
24+
await z.setitem((7,), -99)
25+
# set a range to a constant value using a slice
26+
await z.setitem(slice(0, 3), -1)
27+
# get a slice of the array
28+
await z.getitem((slice(0, 5), ))
29+
# gather multiple items concurrently
30+
await asyncio.gather(z.getitem(slice(0, 5)), z.getitem(slice(6, 10)))
1931
2032
See the API docs for more details:
2133

0 commit comments

Comments
 (0)