@@ -580,6 +580,36 @@ def test_open_datatree_chunks(self, tmpdir, simple_datatree) -> None:
580
580
# from each node.
581
581
xr .testing .assert_identical (tree .compute (), original_tree )
582
582
583
+ def test_open_datatree_path_chunks (self , tmpdir , simple_datatree ) -> None :
584
+ filepath = tmpdir / "test.zarr"
585
+
586
+ root_chunks = {"x" : 2 , "y" : 1 }
587
+ set1_chunks = {"x" : 1 , "y" : 2 }
588
+ set2_chunks = {"x" : 2 , "y" : 3 }
589
+
590
+ root_data = xr .Dataset ({"a" : ("y" , [6 , 7 , 8 ]), "set0" : ("x" , [9 , 10 ])})
591
+ set1_data = xr .Dataset ({"a" : ("y" , [- 1 , 0 , 1 ]), "b" : ("x" , [- 10 , 6 ])})
592
+ set2_data = xr .Dataset ({"a" : ("y" , [1 , 2 , 3 ]), "b" : ("x" , [0.1 , 0.2 ])})
593
+ original_tree = DataTree .from_dict (
594
+ {
595
+ "/" : root_data .chunk (root_chunks ),
596
+ "/group1" : set1_data .chunk (set1_chunks ),
597
+ "/group2" : set2_data .chunk (set2_chunks ),
598
+ }
599
+ )
600
+ original_tree .to_zarr (filepath )
601
+
602
+ chunks = {
603
+ "/" : root_chunks ,
604
+ "/group1" : set1_chunks ,
605
+ "/group2" : set2_chunks ,
606
+ }
607
+
608
+ with open_datatree (filepath , engine = "zarr" , chunks = chunks ) as tree :
609
+ xr .testing .assert_identical (tree , original_tree )
610
+ assert_chunks_equal (tree , original_tree , enforce_dask = True )
611
+ xr .testing .assert_identical (tree .compute (), original_tree )
612
+
583
613
def test_open_groups (self , unaligned_datatree_zarr ) -> None :
584
614
"""Test `open_groups` with a zarr store of an unaligned group hierarchy."""
585
615
0 commit comments