@@ -1270,8 +1270,30 @@ async def array_values(
1270
1270
async for _ , array in self .arrays ():
1271
1271
yield array
1272
1272
1273
- async def tree (self , expand : bool = False , level : int | None = None ) -> Any :
1274
- raise NotImplementedError
1273
+ async def tree (self , expand : bool | None = None , level : int | None = None ) -> Any :
1274
+ """
1275
+ Return a tree-like representation of a hierarchy.
1276
+
1277
+ This requires the optional ``rich`` dependency.
1278
+
1279
+ Parameters
1280
+ ----------
1281
+ expand : bool, optional
1282
+ This keyword is not yet supported. A NotImplementedError is raised if
1283
+ it's used.
1284
+ level : int, optional
1285
+ The maximum depth below this Group to display in the tree.
1286
+
1287
+ Returns
1288
+ -------
1289
+ TreeRepr
1290
+ A pretty-printable object displaying the hierarchy.
1291
+ """
1292
+ from zarr ._tree import group_tree_async
1293
+
1294
+ if expand is not None :
1295
+ raise NotImplementedError ("'expanded' is not yet implemented." )
1296
+ return await group_tree_async (self , max_depth = level )
1275
1297
1276
1298
async def empty (
1277
1299
self , * , name : str , shape : ChunkCoords , ** kwargs : Any
@@ -1504,7 +1526,25 @@ def array_values(self) -> Generator[Array, None]:
1504
1526
for _ , array in self .arrays ():
1505
1527
yield array
1506
1528
1507
- def tree (self , expand : bool = False , level : int | None = None ) -> Any :
1529
+ def tree (self , expand : bool | None = None , level : int | None = None ) -> Any :
1530
+ """
1531
+ Return a tree-like representation of a hierarchy.
1532
+
1533
+ This requires the optional ``rich`` dependency.
1534
+
1535
+ Parameters
1536
+ ----------
1537
+ expand : bool, optional
1538
+ This keyword is not yet supported. A NotImplementedError is raised if
1539
+ it's used.
1540
+ level : int, optional
1541
+ The maximum depth below this Group to display in the tree.
1542
+
1543
+ Returns
1544
+ -------
1545
+ TreeRepr
1546
+ A pretty-printable object displaying the hierarchy.
1547
+ """
1508
1548
return self ._sync (self ._async_group .tree (expand = expand , level = level ))
1509
1549
1510
1550
def create_group (self , name : str , ** kwargs : Any ) -> Group :
0 commit comments