@@ -983,7 +983,9 @@ async def open(
983
983
Examples
984
984
--------
985
985
```python
986
+ import asyncio
986
987
import zarr
988
+ from zarr.core.array import AsyncArray
987
989
988
990
async def example():
989
991
store = zarr.storage.MemoryStore()
@@ -995,8 +997,8 @@ async def example():
995
997
async_arr = await AsyncArray.open(store)
996
998
return async_arr
997
999
998
- # async_arr = await example()
999
- # AsyncArray( ...)
1000
+ async_arr = asyncio.run( example() )
1001
+ # < AsyncArray memory:// ... shape=(100, 100) dtype=int32>
1000
1002
```
1001
1003
"""
1002
1004
store_path = await make_store_path (store )
@@ -1313,18 +1315,21 @@ async def nchunks_initialized(self) -> int:
1313
1315
Examples
1314
1316
--------
1315
1317
```python
1318
+ import asyncio
1316
1319
import zarr.api.asynchronous
1317
1320
1318
1321
async def example():
1319
- arr = await zarr.api.asynchronous.create(shape=(10,), chunks=(1,), shards=(2,) )
1322
+ arr = await zarr.api.asynchronous.create(shape=(10,), chunks=(1,))
1320
1323
count = await arr.nchunks_initialized()
1321
- # 0
1324
+ print(f"Initial: {count}")
1325
+ #> Initial: 0
1322
1326
await arr.setitem(slice(5), 1)
1323
1327
count = await arr.nchunks_initialized()
1324
- # 6
1328
+ print(f"After write: {count}")
1329
+ #> After write: 5
1325
1330
return count
1326
1331
1327
- # result = await example()
1332
+ result = asyncio.run( example() )
1328
1333
```
1329
1334
"""
1330
1335
if self .shards is None :
@@ -1354,18 +1359,21 @@ async def _nshards_initialized(self) -> int:
1354
1359
Examples
1355
1360
--------
1356
1361
```python
1362
+ import asyncio
1357
1363
import zarr.api.asynchronous
1358
1364
1359
1365
async def example():
1360
1366
arr = await zarr.api.asynchronous.create(shape=(10,), chunks=(2,))
1361
1367
count = await arr._nshards_initialized()
1362
- # 0
1368
+ print(f"Initial: {count}")
1369
+ #> Initial: 0
1363
1370
await arr.setitem(slice(5), 1)
1364
1371
count = await arr._nshards_initialized()
1365
- # 3
1372
+ print(f"After write: {count}")
1373
+ #> After write: 3
1366
1374
return count
1367
1375
1368
- # result = await example()
1376
+ result = asyncio.run( example() )
1369
1377
```
1370
1378
"""
1371
1379
return len (await _shards_initialized (self ))
@@ -1595,6 +1603,7 @@ async def getitem(
1595
1603
Examples
1596
1604
--------
1597
1605
```python
1606
+ import asyncio
1598
1607
import zarr.api.asynchronous
1599
1608
1600
1609
async def example():
@@ -1606,10 +1615,11 @@ async def example():
1606
1615
dtype='i4',
1607
1616
fill_value=0)
1608
1617
result = await async_arr.getitem((0,1))
1609
- # array(0, dtype=int32)
1618
+ print(result)
1619
+ #> 0
1610
1620
return result
1611
1621
1612
- # value = await example()
1622
+ value = asyncio.run( example() )
1613
1623
```
1614
1624
"""
1615
1625
if prototype is None :
0 commit comments