2929 _join_paths ,
3030 _normalize_path_keys ,
3131 _normalize_paths ,
32+ _parse_hierarchy_dict ,
3233 _read_node ,
3334 create_hierarchy ,
3435 create_nodes ,
@@ -1642,6 +1643,7 @@ async def test_create_rooted_hierarchy_group(store: Store, zarr_format, path: st
16421643 )
16431644 for node_name in group_names
16441645 }
1646+
16451647 arrays_expected_meta = {
16461648 _join_paths ([root_key , node_name ]): meta_from_array (np .zeros (4 ), zarr_format = zarr_format )
16471649 for node_name in array_names
@@ -1660,6 +1662,18 @@ async def test_create_rooted_hierarchy_group(store: Store, zarr_format, path: st
16601662 }
16611663 assert members_observed_meta == members_expected_meta_relative
16621664
1665+ @pytest .mark .parametrize ("store" , ["memory" , "local" ], indirect = True )
1666+ def test_create_hierarchy_implicit_groups (store : Store ):
1667+ spath = sync (make_store_path (store , path = '' ))
1668+ nodes = {
1669+ '' : GroupMetadata (zarr_format = 3 , attributes = {'implicit' : False }),
1670+ 'a/b/c' : GroupMetadata (zarr_format = 3 , attributes = {'implicit' : False })
1671+ }
1672+
1673+ hierarchy_parsed = _parse_hierarchy_dict (nodes )
1674+ g = _create_rooted_hierarchy_sync (spath , nodes = nodes )
1675+ for key , value in hierarchy_parsed .items ():
1676+ assert g [key ].metadata .attributes == value .attributes
16631677
16641678# TODO: simplify testing sync versions of async functions.
16651679@pytest .mark .parametrize ("store" , ["memory" , "local" ], indirect = True )
@@ -1721,9 +1735,32 @@ async def test_create_rooted_hierarchy_array(store: Store, zarr_format, path: st
17211735 nodes_create = root_meta
17221736
17231737 a = await _create_rooted_hierarchy (spath , nodes = nodes_create , overwrite = True )
1738+ assert isinstance (a , AsyncArray )
1739+ assert a .metadata .attributes == {"path" : root_key }
1740+
1741+ @pytest .mark .parametrize ("store" , ["memory" , "local" ], indirect = True )
1742+ @pytest .mark .parametrize ("zarr_format" , [2 , 3 ])
1743+ @pytest .mark .parametrize ("root_key" , ["" , "root" ])
1744+ @pytest .mark .parametrize ("path" , ["" , "foo" ])
1745+ async def test_create_rooted_hierarchy_sync_array (store : Store , zarr_format , path : str , root_key : str ):
1746+ """
1747+ Test that _create_rooted_hierarchy_sync can create an array.
1748+ """
1749+ spath = await make_store_path (store , path = path )
1750+ root_meta = {
1751+ root_key : meta_from_array (
1752+ np .arange (3 ), zarr_format = zarr_format , attributes = {"path" : root_key }
1753+ )
1754+ }
1755+
1756+ nodes_create = root_meta
1757+
1758+ a = _create_rooted_hierarchy_sync (spath , nodes = nodes_create , overwrite = True )
1759+ assert isinstance (a , Array )
17241760 assert a .metadata .attributes == {"path" : root_key }
17251761
17261762
1763+
17271764async def test_create_rooted_hierarchy_invalid ():
17281765 """
17291766 Ensure _create_rooted_hierarchy will raise a ValueError if the input does not contain
0 commit comments